2 ms·
I posted an explanation of how Dylan's macro system would handle this elsewhere (including http://www.reddit.com/r/programming/comments/2gesag/comparative_macro
by BruceM 12y ago
I posted an explanation of how Dylan's macro system would handle this elsewhere (including http://www.reddit.com/r/programming/comments/2gesag/comparative_macrology/ckihk2b http://www.reddit.com/r/programming/comments/2gesag/comparat...).
Dylan was one of the original languages to have an infix-syntax with a Lisp / Scheme style macro system. (It is fairly similar to Scheme's syntax rules, but there's an implementation of something more powerful that is used within the compiler but isn't currently available to users.)
The examples that he is demonstrating in the other languages would like this in Dylan:
define macro swap!
{ swap! (?place1:expression, ?place2:expression) }
=>
{ let value = ?place1;
?place1 := ?place2;
?place2 := value; }
end;
and:
define macro each-it
{ each-it (?collection:expression)
?:body
end }
=>
{ for (?=it in ?collection)
?body
end };
end;
Dylan's macros are hygienic by default, and as can be seen in the ``each-it`` macro, ``?=it`` is a way to violate hygiene without much difficulty, when needed.
My full post as linked above contains links to documentation and other minor details.