Pit Capitain
1/27/2007 2:44:00 PM
Martin C. Martin schrieb:
> In Lisp, it's easy to get the parse tree of an expression, and to
> manipulate those parse trees. That means Lisp code tends to use macros,
> i.e. lisp functions whose return values are parse trees. These macros
> are evaluated at compile time and inserted into the place where the
> macro call appears.
>
> Is there anything equivalent in Ruby? Is there a way in Ruby to get the
> parse tree of, say, x + y? Is there a way to execute parse trees?
Martin, in addition to what Aaron has written, I'd like to ask you what
you need this for. I've been playing with implementing macros in Ruby a
few times, but I found no compelling reason to support them in Ruby.
Yes, I could do some nice tricks, but I think they haven't been worth
the trouble. So I'd be interested in your use cases.
Regards,
Pit