Mike Austin's Blog

Tuesday, October 11, 2005

Dylan macro system is badass!

We're not talking C/C++ crapy preprocessors or LISP macros, the Dylan macro facility is a type of BNF translator, able to translate most any syntax or grammar. Behold, I can convert a non-oo looking method definition:
define method move-to (self :: <window>, x, y)
end;
Into this:
define-method <window>.move-to(x, y)
end;
With this little macro:
define macro define-method
{ define-method ?class:name . ?name:name (?params:*)
?:body
end } =>
{ define method ?name (?=self :: ?class, ?params)
?body
end }
end;
Nice!

3 Comments:

Post a Comment

<< Home