How it goes ... you add rules for new syntax, and your macro-handler receives a syntax tree. And you transform that into a regular AST that the interpreter can understand ... more or less as in LISP.
The difference is that in LISP you work directly with ASTs ... while in Perl you can access the compiler's pipeline.
This idea is not new ... for instance it's also implemented in Boo (boo.codehaus.org) ... although I don't know how effective is.
And Perl 5.12 has this jewel in its changelog:
New experimental APIs allow developers to extend Perl with "pluggable" keywords and syntax.
The stuff in core is, however, way, way more elegant than the way Devel::Declare currently does it - which was rather the point, Devel::Declare was "retrofit to existing perl5 VMs what will hopefully be core later".
Here is the code example from the docs:
use XS::APItest::KeywordRPN qw(rpn calcrpn);
$triangle = rpn($n $n 1 + * 2 /);
calcrpn $triangle { $n $n 1 + * 2 / }Also I think the the ability for a program to create a new program (I assume you mean on the fly) is probably inherent in all dynamic languages.
Constructing macros in Lisp however /is/ something you do lightly. A typical lisp program might have a 20/80 division of macros/functions. You aren't going to see a sane program in other languages that do the same thing.
For all the ease with which one can create macros in LISP, I haven't seen anything comparable to LINQ yet.
And while I've seen useful macros here and there, I haven't seen anything groundbreaking ... macros are mostly used when you need laziness.
Powerful? Yes. Easy to use? No.
Common SQL : http://www.lispworks.com/documentation/sql-tutorial/index.ht...
(loop for columns being the records of
[select [*] :from [SpeciesList]
:where aardvark]
do (print columns))
Common SQL provides some kind of embedded SQL that gets expanded with read macros and macros to more low-level Lisp code.