From: Avi Bryant Date: 2001-10-25T14:51:08+09:00 Subject: [ruby-talk:23262] Re: Ruby macros On Thu, 25 Oct 2001, Leo wrote: > Hi Ruby experts, > I think that some sort of macro system similar to one found in Lisp or Scheme > would clearly set Ruby over its rivals like Perl/Python. > In the past I did some programming in Lisp and Scheme and I loved macros. > They are very useful and some times indispensable. > Not having them in Ruby is IMHO a last missing feature on Ruby's path > to world domination:) I'm also a big fan of macros, although I tend towards somewhat more flexible metaprogramming styles (see http://www.cs.ubc.ca/labs/spl/projects/explicit.html for a vague idea of what I mean). However, I've had this discussion with Matz more than once, and he is not interested in having macros in Ruby (at least, not in as general a way as they're found in lisp and scheme). This doesn't mean we can't add them ourselves - I've considered, for example, building an s-expression syntax for ruby to make macros more feasible. When a few of us were talking about this at RubyConf, Dave Thomas proposed a construct where the "is" keyword would pass the preceding syntactic element to whatever method followed it - ie, class A; end is foo would more or less trigger: foo("class A; end") But your idea of macro methods is interesting too - I believe the research language Agora does something very close to this. Useful work includes the recent RubyInRuby parser and Robert Feldt's Ruth wrapping of the parse nodes in Ruby. If anyone is seriously interested in Ruby metaprogramming (or more specifically, in the terminology of my little research group, Explicit Programming in Ruby), let me know, as I may have some time in the next few months to put some work into this.