From: Yohanes Santoso Date: 2004-08-05T20:19:50+09:00 Subject: Re: Macros in Ruby "David A. Black" writes: >> 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 Hi David, My example is incomplete. There should be this following that: docstring(:foo) #=> "This method will return arg" > 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 In my reply to gabriele, I mentioned that I do not know if macro can save one from an invalid syntax since my experience with macro is limited to CL's and elisp's macros which won't work if the syntax is invalid. Rather, what the example above shows that with macro you can change the semantic of method definition, i.e.: if there is a string at the top of the method body, take that as the docstring for that method, instead of giving a warning about unused literal. Sorry, I am unable to come up with a likely macro definition that would allow the above example to be true. I had difficulty imagining how you can define such macro in ruby; my imagination is lacking. I also believe that macro, like any other tool, can be used for good or evil. More importantly, I do not care if Ruby has macro or not, although now that I have more time to think since my reply to gabriele, I am leaning toward leaving things the way it is (without macro) since macro is susceptible to being abused. Good day, YS.