From: "David A. Black" Date: 2004-08-05T19:59:44+09:00 Subject: Re: Macros in Ruby Hi -- On Thu, 5 Aug 2004, Yohanes Santoso wrote: > Rando Christensen writes: > > > The macro version has made the code much less clear in my mind, which is > > precisely the argument against macros in ruby. > > Actually, the example Jesse gave was probably bad. A macro, like any > other language construct, can be created to enhance clarity or > obfucate. Thus, one should not make a hasty judgement based on that > one example. > > How about this example (which I hope is a better example of > easy-with-macro,-hard-(impossible?)-without): > > Suppose we want to do self-documenting methods (not source file), > similar to docstring in emacs: > > An implementation with macro would look something like: > > def foo(arg) > "This method will return arg" > arg > end You can already do that, if you don't mind a warning with -w :-) But assuming you intend a macro to let you do things that are otherwise illegal syntax, that's where the problem arises of having everyone's code, potentially, look and act different, and, as others have said, just not to look like Ruby. (Unless we define "Ruby" as "a macro language in which any syntax is possible", but I'd rather not :-) David -- David A. Black dblack@wobblini.net