On Mon, 12 Mar 2007, Mike wrote: > I know it but imagine you must do it 100 times? > I'd rather write: > set_default(var1, 15) > set_default(myvar1, "string") > ... > set_default(lastvar, myhash) > > In your case I must use "var" twice. Don't you think it is too much? in that case i'd probably just use var1 ||= 15 or instance variables. there a so many ways to skin that cat. you could do something subversive like this if yoiu really wanted to harp:~ > cat a.rb require 'binding_of_caller' def set_default a, &b @set_default = b Binding.of_caller do |binding| eval " class << self define_method '#{ a }', &@set_default end ", binding end end 100.times{|i| set_default(:x){ i + 1 } } p x #=> 100 i guess i see that there are times when a macro might make things faster to write, but the tradeoff, as we all know, it that they are then slower to debug. in the end you cannot do anything you coulnd't without one and it can substantially confuse debugging when text substitution, dynamic scoping, and closures are mixed. consider later = Queue.new #define now( x ) later.push(lambda{ x }) x = 40 now(x += 2) p x #=> 40 sleep rand p x #=> 42 regards. -a -- be kind whenever possible... it is always possible. - the dalai lama