From: Lennon Day-Reynolds Date: 2004-08-03T02:45:10+09:00 Subject: Re: Macros in Ruby On Tue, 3 Aug 2004 02:29:34 +0900, James Britt wrote: > Is there something different about Ruby such that what (supposedly) > works to such acclaim in Lisp would be inappropriate in Ruby? A: S-expressions, or the lack thereof in Ruby. Lisp code can always be manipulated as a simple tree of cons cells; Ruby code, even if a high-level programmatic interface existed to the AST, has a much richer syntax, and therefore more complex structure. Also, as has been mentioned, Ruby largely replaces macros with blocks -- they allow delayed evaluation, specialized iteration and pre/post-condition checks, etc. Many of the common macros you'll see in Lisp are things like this: (with-open-file "foo.dat" my-file (case (read-char my-file) ...)) [my apologies for the weird function names; it's been a couple of years since I was actively developing any Lisp code] Obviously, that example is quite handily supported by the more Ruby-esque example below: open("foo.dat") {|my_file| case my_file.getc ...} Personally, I think macros could be an interesting tool for very special cases, but they're not an essential feature for 90% of developers. Now, exposing the AST with a high-level API could have other benefits: code analysis and optimization, JIT compilers, documentation generators, etc. Lennon