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

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-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 %))

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