From: ThoML Date: 2008-02-08T23:14:59+09:00 Subject: Re: Symbol#to_proc, lazy evaluation (was Re: idiom I've not seen before) > Io (like Lisp, I gather) allows lazy evaluation of method arguments. Are you referring to Lisp's macro facility? AFAIK macros are usually expanded at load/compile time. Since everything is a s-expression in lisp, the macro gets its arguments as list and can process them. The macro call is then replaced with the result. Or something along this line. It seems Io provides a similar facility to treat code as data, which is cool. Unfortunately I'm not able to compile it. IIRC Forth was able to do something similar too BTW (just a side-note). Since ruby doesn't have this feature (unless you use parsetree and ruby2ruby maybe), the ruby equivalent are strings, I'd say. One could thus write something like: class Array def select_by(snippet) rv = [] self.each do |e| rv << e if e.instance_eval '%s %s' % [e.inspect, snippet] end rv end end a = [1,2,3,4,5] a.select_by '> 3' Which is about the same as your io example. It would be nice of course to be able to have real macros that are expanded at load time so that one could write something like the following which is incorrect ruby syntax and would have to be rewritten before the parser tries to make sense out of it: module Macros def select_by(code) %{select {|e| e #{code}}} end end a = [1,2,3,4,5] a.select_by(> 3) This would require that macro names are unique though. But it's just a delirious day-dreaming anyway. Regards, Thomas.