From: Wayne Vucenic Date: 2005-12-04T08:49:55+09:00 Subject: Re: IL Generator syntax proposal Hi John, It was great meeting you at RubyConf! We can avoid having to do all the "g." prefixes on the methods like this: module CLR_IL def use_generator(g) @il_generator = g end def begin_exception_block @il_generator.begin_exception_block end def call(s) @il_generator.call(s) end end then your example becomes d = DynamicMethod.new("Int32, UInt32*, UInt32") g = d.get_generator use_generator(g) begin_exception_block do call "static Throws.ThrowException()" br_s "EndOfMethod" ...etc... Of course, we could use method_missing in module CLR_IL to avoid having to write each of the individual wrappers that forward to @il_generator.whatever. Wayne Vucenic No Bugs Software "Ruby and C++ Agile Contract Programming in Silicon Valley" On 12/2/05, John Lam wrote: > In my rewrite of my Ruby <=> CLR bridge, I've been thinking about pushing > most of the logic into Ruby, and leaving as little as possible in Managed > C++. I was just hacking around this morning in emacs thinking about what the > syntax for an IL generator should look like, and this was what I came up > with: > > d = DynamicMethod.new("Int32, UInt32*, UInt32") > g = d.get_generator > > g.begin_exception_block do > g.call "static Throws.ThrowException()" > g.br_s "EndOfMethod" > g.catch("Exception") do > g.call "ToString()" > g.call "static Console.WriteLine(String)" > end > g.label "EndOfMethod" > g.ldc_i4 Qnil > g.ret > end > > I'd love it if folks could comment on how this syntax might be improved in > Ruby before I crank out the underlying MC++ / Ruby code ... > > Thanks! > -John > http://www.iunknown.com > >