Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Can your fucking language do this?

Name: Anonymous 2013-01-25 13:54

http://perl6advent.wordpress.com/2012/12/18/day-18-formulas-resistance-is-futile/


Seriously, i really want to know if there are some "real world" languages that can implement such syntax "extensions"

Name: Anonymous 2013-01-25 14:19

Java.

Name: Anonymous 2013-01-25 14:34

>>2
How? An example... please???

I didn't know that Java allowed even to overload operators..

Have you read the article or are you just trolling?

Name: Anonymous 2013-01-25 14:38

>>2
Trolling, obviously.  Almost every language will allow you to do something like this, though

(scientific-parse "4.7kΩ ± 5%")

for some implementation of scientific-parse.

Name: Anonymous 2013-01-25 14:44

>>4
I know that any language can implement a text parser for any expression. That's not a big deal. I'm not talking about that. I'm talking about "extending" the language for understanding such expressions.

Name: Anonymous 2013-01-25 15:04

>>5
Tell me when that's actually useful.

Name: Anonymous 2013-01-25 15:07

You could probably make a stupid Lisp macro that can parse S-exps like (4.7 kΩ ± 5.0 %).

Name: Anonymous 2013-01-25 15:32

my $factory MeasureFactory.getSharedInstance();
my $resistance = $factory.createMeasure(value     => 4700,
                                        unit      => Unit::ohm,
                                        precision => 5);


What an ugly solution for what is basically just '(ohm 4700 .05)

Name: Anonymous 2013-01-25 15:57

Any turing complete language

Name: Anonymous 2013-01-25 16:05

>>6
Having compile-time syntax checks, and possibly type checks. Also, not having to write a whole fucking parser.

Name: Anonymous 2013-01-25 16:45

>>1
Symta.

Name: Anonymous 2013-01-25 17:55

>>11
Example plz?

Name: Anonymous 2013-01-25 20:18

>>11
unimpressive dubs

Name: Anonymous 2013-01-25 20:25

>>11
No. Long time ago I removed the ability to introduce new operators. Symta is very strict regarding function names: ids must must start from lowercase letter and include at least 2 charaters, because all 1-letter names are reserved for common functions, like map and fold.

Name: Anonymous 2013-01-26 0:21

>>1
Perl is unique in allowing you to mess with the grammar like that. Prolog allows you to define infix operators with over 9000 different levels of precedence. Like >>4 said, this is possible in any language by interpreting strings at runtime. With lisp, you can force the interpretation of the string to occur at compile time by defining the string interpretation function as a macro. The more lispy way to do it though would be to represent these new expressions as syntax trees, and maybe have a outer most macro that explores the syntax tree and produces an instance of some object that it represents. This is a good approach because you don't need to worry about compatibility as much. With perl, two libraries that fuck around too much with the grammar might cause problems with each other. But with lisp all the new loopy code is contained within an outer macro. You might not be able to use one macro inside of another, but you'll always be able to use both separately.

Anyways, one approach in lisp:

(scientific-quantity (± (4.7 k Ω) (5 %))

Name: Anonymous 2013-01-26 0:59

>>15
If you find yourself typing that over and over, why not define a macro "sci" and write (sci 4.7kΩ ± 5%) and have it process that at compile time macroexpansion time?

Name: Anonymous 2013-01-26 3:19

>>16
Because I'd rather type (sci 4.7 k Ω 5)

Name: Anonymous 2013-01-26 5:47

http://perl6advent.wordpress.com
D!R

>>16
Yeah, on your personal pref. header. Be sure to recompile and output the code back to scientific-quantity.

Name: Anonymous 2013-01-26 14:25

javascript has always been able to do this

are you even trying?

Name: Anonymous 2013-01-26 14:55

>>19
LEEEEEEEEEEEL LE JAVASCRIPT E/G/IN XD

Name: Anonymous 2013-01-26 14:58

>>19
Back to the gas oven, Rabbi Chaim Abraham Goldstein.

>>22
Fuck off, illogical libtard Reddit shitstain.

Name: Anonymous 2013-01-26 15:05

Name: Anonymous 2013-01-26 17:22

>>21
Fuck off, illogical racist piece of cretinoid shit.

Name: Anonymous 2013-01-26 17:48

>>23
Fuck off, illogical libtard Reddit shitstain.

Name: Anonymous 2013-01-26 18:22

>>24
Fuck off, illogical racist piece of cretinoid shit.

Name: Anonymous 2013-01-26 18:24

>>25
Fuck off, illogical libtard Reddit shitstain.

Name: Anonymous 2013-01-26 18:26

>>26
Fuck off and die in a fire, illogical racist piece of cretinoid shit.

Don't change these.
Name: Email:
Entire Thread Thread List