In article <126117684609.20040802210655 / scriptolutions.com>, Lothar Scholz <mailinglists / scriptolutions.com> wrote: > Hello jim, > > >> However i think it is quite easy to emulate some form of macro > >> functionality in Ruby. Here is some simple code: > > jfo> I've heard Matz say that Ruby will not support macros. > > And i hope that he never changes his opinion at this topic. > > jfo> They are too easily abused and can mutate the language. > > They easily make code much more unreadable. Banning a feature because it can be misused is a pretty weak rationale. It might make sense for something like goto where you can provide more structured alternatives that take care of most cases, but I don't think macros fall into this case. It's been said in this thread that Ruby doesn't need macros because it has blocks but, this too, seems like a very weak argument. After all Lisp is famous for its support for closures and Lisp programmers still value the maro support in Lisp. From what I can tell macros offer three benefits: 1) They allow you to extend the syntax of the language to directly support your problem domain. For example, if you work with finite-state machines you can write a macro that allows you to declaratively define FSMs. 2) Macros allow you to evaluate arguments zero or more times whereas functions and blocks normally eagerly evaluate arguments once. 3) Macros are inlined so they may execute faster than a block. Of these benefits, blocks only address point two and that in a rather clunky fashion. > I think that languages > like D, C# etc now exactly why they don't want something like macros. How so? I don't know these languages well, but I don't see that they've done anything to address the problems macros were designed to solve. They've merely omitted features like meta-programming, dynamic typing, full multiple inheritance, etc where they thought the cost out-weighed the benefits. > As said before lisp is different because of the general S-Expression > style of this language. Different only in that it's easier to implement macros in Lisp. But more conventional languages, like Dylan, also support macros. -- Jesse