Forum: IronRuby Is it possible to yield C# code?

Posted by "Jonas Elfström" <jonelf@gmail.com> (Guest)
on 2010-11-30 00:06
(Received via mailing list)
I'm sorry if this is the wrong list. Please direct me if so.

This is not really something I'm losing sleep over but still I'm a
fair bit curious to know if it's possible to yield code that's not
Ruby from IronRuby. Is it?

The following C# gives me a wrong number of arguments (1 for 0) 
exception.

delegate void del(string s);
...

var rt = Ruby.CreateRuntime();
var eng = rt.GetEngine("rb");
eng.Execute(@"
            class YieldTest
              def test
                yield 'From IronRuby'
              end
            end
            ");
object test = eng.Runtime.Globals.GetVariable("YieldTest");
dynamic t = eng.Operations.CreateInstance(test);
t.test((del)(s => Console.WriteLine(s)));

See 
http://stackoverflow.com/questions/4189955/calling...

If this is not possible, is it then a kind of integration that is
planned for future releases of IronRuby?
Posted by Tomas Matousek (Guest)
on 2010-11-30 18:47
(Received via mailing list)
It is not possible today, it might be possible in future :)

BTW, I would suggest to use Action<string> instead of defining your own 
delegate type.

Tomas
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.