[Ironruby-core] RubyModule CreateAnonymousModule - NotImplementedException

Ben Hall ben2004uk at googlemail.com
Sat Sep 27 18:10:20 EDT 2008


Hi Peter,

Thanks for your reply. That is what I tried initially, however you
need to return a RubyModule object. I tried:

return (RubyModule) RubyUtils.EvaluateInModule(module, block);

but I get the errror:

E:\IronRuby\trunk\src\Microsoft.Scripting.Core\Actions\MatchCaller.Generated.cs:35:in
`Call3': Unable to cast object of
type 'IronRuby.Builtins.Proc' to type 'IronRuby.Builtins.RubyModule'.
(System::InvalidCastException)
        from E:\IronRuby\trunk\src\Microsoft.Scripting.Core\Actions\CallSite.cs:275:in
`UpdateAndExecute'
        from E:\IronRuby\trunk\src\Microsoft.Scripting.Core\Actions\UpdateDelegates.Generated.cs:45:in
`Update3'
        from step.rb:19:in `init_module'


I tried this implementation:
            RubyModule module = new RubyModule(self);
            module.Name = SymbolId.Empty;
            RubyUtils.EvaluateInModule(module, block);
            return module;

When appears to allow me to progress some more, but now i'm hitting
LocalJumpError("unexpected return"); in
RuntimeFlowControl.BlockReturn, I guess something isn't correct.


Out of interest, what documentation is available?

Thanks

Ben


On Sat, Sep 27, 2008 at 5:08 PM, Peter Bacon Darwin
<bacondarwin at googlemail.com> wrote:
> The documentation says that the block version of the code creates the
> anonymous module and then passes this new module to the block via a dynamic
> call to Module#module_eval.
> The following code is a quick hack (that may work!!) but really we should be
> hitting a DynamicSite to invoke the module_eval.
>
>        // Ruby constructor:
>        public static object CreateAnonymousModule([NotNull]BlockParam/*!*/
> block, RubyClass/*!*/ self) {
>            RubyModule module =
> self.ExecutionContext.DefineModule(SymbolId.Empty);
>            return RubyUtils.EvaluateInModule(module, block);
>        }
>
> Disclaimer: I haven't tried this at all.
> Pete
>
> -----Original Message-----
> From: ironruby-core-bounces at rubyforge.org
> [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Ben Hall
> Sent: Saturday,27 September 27, 2008 13:54
> To: ironruby-core at rubyforge.org
> Subject: [Ironruby-core] RubyModule CreateAnonymousModule -
> NotImplementedException
>
> Hello,
>
> Just been playing around with IronRuby, however I am hitting an issue
> with RubyModule.CreateAnonymousModule() - basically, it hasn't been
> implemented yet :)
>
> // Ruby constructor:
> public static RubyModule/*!*/
> CreateAnonymousModule([NotNull]BlockParam/*!*/ block, RubyClass/*!*/
> self) {
>  // TODO:
>  throw new NotImplementedException();
> }
>
> You have implemented another method:
> public static RubyModule/*!*/ CreateAnonymousModule(RubyClass/*!*/ self) {
>   return self.ExecutionContext.DefineModule(SymbolId.Empty);
> }
>
> But I don't know how to to implement with relation to the block.  Is
> it just not supported yet?
>
> If you could provide me with any help that would be great, its really
> blocking me at the moment.
>
> Thanks
> Ben
> _______________________________________________
> Ironruby-core mailing list
> Ironruby-core at rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core
>
> _______________________________________________
> Ironruby-core mailing list
> Ironruby-core at rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core
>


More information about the Ironruby-core mailing list