From: ptkwt@... (Phil Tomson) Date: 2004-08-04T10:06:32+09:00 Subject: Re: Macros in Ruby In article <030820041658374069%jesjones@mindspring.com>, Jesse Jones wrote: >In article , Phil Tomson > wrote: > >> While Matz may have 'banned' macros from the core language, that doesn't >> mean that if someone comes up with a way to do LISP-like macros >> implemented in an external module, (that could be downloaded >> from the RAA for example) that Matz would ban the module. He probably >> would never consider bundling it with the Ruby distribution, of course, >> but that doesn't mean it would be 'banned'. > >This seems hard to do well. A good macro system really needs to be >integrated into the language. If not, you wind up with abortions like >the C/C++ macro system which is both dangerous to use and >under-powered. > >It might be possible to do with an open compiler (ie one that provided >hooks to allow third-party components to affect its behavior). I tend >to be a bit suspicious of open compilers though. They seem to either >lock users into particular implementations or significantly constrain >compiler implementations. I'll have to think about it some more, but it >seems like adding macros wouldn't be all that much more difficult to >implement than opening the parser up. > >> It's kind of like how the static typing advocates occasionally come up >> with some code for emulating static typing in Ruby (and you can probably >> find some on the RAA) while most of us think that such things are >> ill-advised, no one is stopping the advocates of such things from using >> it. > >I don't see the connection. Static typing runs counter to the whole >concept of typing in Ruby. Macros, on the other hand, are a completely >orthogonal concept and, if anything, fit well into the Ruby philosophy >of providing a flexible and expressive language. Read my later post. I was only using that debate as an example... There is a camp of folks who think that Ruby needs to emulate static-typing in some cases. There is another camp that thinks this is a bad idea. Similarly, there is a camp that says that macros would be useful (or at least interesting to explore - that's kind of where I'm at since I've never used LISP macros) and there is another camp (which Matz is in) that says that macros are just plain bad. Since Matz is in the latter camp you're not likely to see macros included in Ruby 'out-of-the-box', but if you can some up with an addon to do macros (if it's possible)... I wasn't trying to tie static typing and macros together. Phil