3 ms·
Metalua, Nemerle, Boo (and even Perl to some extent) ... among other languages have support for compile time macros / interacting with the compiler's pipeline.
by bad_user 16y ago
Metalua, Nemerle, Boo (and even Perl to some extent) ... among other languages have support for compile time macros / interacting with the compiler's pipeline.
Here's the LINQ syntax built as a Nemerle macro ... http://code.google.com/p/nemerle/source/browse/#svn/nemerle/trunk/Linq/Macro%3Fstate%3Dclosed http://code.google.com/p/nemerle/source/browse/#svn/nemerle/...
Where a query looks like this ...
def res = linq <# from c in customers where c.City == "London" #>;
Of course, it requires a prefix "linq" + the actual code to be delimited ... but that's not a requirement, as that macro could've been built to look exactly as the C# equivalent (the current form being chosen to prevent ambiguities both for the compiler and the programmer).
Here's MooseX-Declare, which introduces completely new syntax in Perl ... http://search.cpan.org/dist/MooseX-Declare/lib/MooseX/Declare.pm http://search.cpan.org/dist/MooseX-Declare/lib/MooseX/Declar...
So the argument that you need Lisp-like syntax for adding syntax to a language without storing it in strings or through pre-processing ... is bullshit.
The only difference between a language like Nemerle and Lisp is that in Lisp a macro is easier to write, while in Nemerle you need some knowledge about the compiler's parser / AST and pipeline.
But having easy-to-write macros ... I'm not sure it's such a good thing ... and in Nemerle you're not limited in the kind of syntax you can add to the language. In fact Nemerle is a simple core language where many of the useful things in it are built as macros.