Here’s a beautiful little code frag that Robert Klemme posted to ruby-talk this morning. It solved an important problem that I had with my CIL DSL that I posted last night. I didn’t really understand the alternative block syntax until I saw it used in this context:

module Bob
def method_missing(name, *params)
puts "missing: #{name}"
end
def self.create(name, &b)
obj = Object.new
obj.extend Bob
obj.instance_eval(&b)
puts name
end
end
Bob::create('hi') do
ldstr
ldc_i4_0
end