Toby DiPasquale on 7 Dec 2005 14:33:48 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PhillyOnRails] meeting followup


On Wed, Dec 07, 2005 at 08:58:30AM -0500, Roger Jack wrote:
> Thanks for a great presentation. I have a follow up question. You mentioned
> that one of the few things that Ruby is missing is Macros. You also said it
> looks like Macros will be added to Ruby.
> 
> What exactly are Macros? 

Sorry, macros are just a compile-time program text replacement system that
allows a developer to "extend" the language in certain ways. The kind of
macros that I was referring to, LISP macros, share little with their C
macro cousins, in that LISP macros are actually written in LISP and are
therefore very powerful (allowing arbitrary code generation). The reason I
mentioned it is that there are 9 things a programming language needs to be
a LISP, and Ruby is missing only macros to complete that list (well, and
keyword arguments, but those are definitely coming in some form or another
in the next version of Ruby).

If you don't mind reading some LISP examples, check out these sections of
"Practical Common Lisp" for a taste of what full-power macros are like:

http://gigamonkeys.com/book/macros-standard-control-constructs.html
http://gigamonkeys.com/book/macros-defining-your-own.html

Ruby *could* get macros, but its unclear as to whether it ever will. I
haven't seen much discussion on it lately which means either the community
doesn't want them or doesn't know about them. I'm also unsure as to matz's
feelings on the subject and he's the ultimate arbiter of such features.
There are some significant technical hurdles as well, in that LISP macros
are based on the fact that in LISP, code and data are formatted
identically (which is not the case in Ruby). For this reason as well,
Python will probably never get macros (mandatory whitespace makes that a
virtual impossibility).

-- 
Toby DiPasquale
_______________________________________________
talk mailing list
talk@phillyonrails.org
http://lists.phillyonrails.org/mailman/listinfo/talk