From: Brian Candler Date: 2003-04-13T02:19:11+09:00 Subject: Re: The "!" and "?" characters. On Sun, Apr 13, 2003 at 01:04:53AM +0900, Ryan Pavlik wrote: > I wonder at this... Lisp has macros, and they don't make it harder > to read. Perhaps because it is impossible to make Lisp harder to read :-)) > Actually, Lisp-style macros applied to ruby would be somewhat > more like a simple eval, where you might go (in pseodoruby): > > defmacro c_for(st1, st2, st3) > #{st1} > while(#{st2}) > yield > #{st3} > end > end ... > c_for(i = 0, i < 200, i += 1) { > ... > } I'm not sure if that's the best example, because you can do that anyway if st1/st2/st3 are proc objects: def c_for(st1, st2, st3) st1.call while(st2.call) yield st3.call end end i = nil c_for(proc {i = 0}, proc {i < 10}, proc {i += 1}) do puts i end I'm not a Lisp hacker (I've tried and failed there), but are Lisp macros more powerful than that? Passing in a proc object means that it's pre-parsed, oven-basted and ready-to-run. Furthermore you can pass them around as first-class objects: def make_c_for(st1, st2, st3) proc { st1.call while(st2.call) yield st3.call end } end i = nil myloop = make_c_for (proc {i = 0}, proc {i < 10}, proc {i += 1}) do puts i end myloop.call This kind of function composition was something I saw quite a lot of when trying to learn Lisp. Regards, Brian.