Add top_self "main" object #327

Closed
wants to merge 1 commit into
from

Projects

None yet

4 participants

@Blorgus

Please review and let me know if this is acceptable.

@masuidrive

Sure.
I try to usr global variable instead of instance variable.

@matz matz added a commit that closed this pull request Sep 2, 2012
@matz matz introduce toplevel object main; close #327 fd3af6a
@matz matz closed this in fd3af6a Sep 2, 2012
@jfcalvo

It is mrb->object_class reference the correct way to add a method to the toplevel object main? For example:

...
mrb_state *mrb = mrb_open();
mrb_define_method(mrb, mrb->object_class, "sqrt", custom_sqrt, ARGS_REQ(1));
...
@matz
mruby member

If you want to add global methods (methods available everywhere in your program), yes.
If you want to add singleton methods to the toplevel object main, currently there's no way, right now.

@jfcalvo

I was trying to create a global method. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment