Hello, I'm kenichi hashimoto.
I'm a Japanese. I don't write english well.

Now I have a question about a canonical style for writing the IronRuby
hosting code.

[BACKGROUND]
Now, I'm tring to host the IronRuby 1.0RC on C#.NET (Visual Studio 2008).
And, I have been trying to host it since IronRuby 0.5.
However, I haven't understood about how to write code in right style yet.

[QUESTION]
Could you please teach a canonical style for writing the IronRuby hosting code.

Now, I wrote below:

    static void Main(string[] args)
    {
        // create the IronRuby engine.
        ScriptRuntime runtime = IronRuby.Ruby.CreateRuntime();
        var engine = runtime.GetEngine("rb");

        // create the scope and set the local variable from C#
        var scope = engine.CreateScope();
        scope.SetVariable("x", 123);

        // set the global variable from C#
        IronRuby.Ruby.GetExecutionContext(engine).DefineGlobalVariable("xxx",
789);

        // execute the script with the scope
        var source = engine.CreateScriptSourceFromString(@"puts ""x is
#{x}. $xxx is #{$xxx}."" ");
        source.Execute(scope);

        Console.ReadLine();
    }

Is it a canonical style?

Thank you.
B.R. Kenichi HASHIMOTO
_______________________________________________
Ironruby-core mailing list
Ironruby-core@rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core

Reply via email to