Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BasicObject's instance methods #3417

Closed
catsidhe opened this issue Jan 26, 2017 · 3 comments
Closed

BasicObject's instance methods #3417

catsidhe opened this issue Jan 26, 2017 · 3 comments

Comments

@catsidhe
Copy link

catsidhe commented Jan 26, 2017

BasicObject.instance_methods

Ruby:

[:!, :==, :!=, :__send__, :equal?, :instance_eval, :instance_exec, :__id__]

mruby:

[:method_missing, :initialize, :!]

Is there a reason for this difference? In particular, #__send__ can be pretty useful.

One workaround is to use eval("obj.#{method_name}(*args, &block)"), but it's obviously a poor solution.

Another potential workaround:

Kernel.instance_method(:send).bind(obj).call(:method_name)

crashes with:

Segmentation fault: 11

(both Object and BasicObject)

@ksss
Copy link
Contributor

ksss commented Jan 28, 2017

It's interesting.
I don't know why BasicObject#__send__ is nothing.

But,

Kernel.instance_method(:send).bind(obj).call(:method_name)

It might be mruby-method's problem.
I'll check it later.

matz added a commit that referenced this issue Feb 15, 2017
More compatibility to CRuby.
Updated tests that assume old mruby behavior.
matz added a commit that referenced this issue Feb 15, 2017
matz added a commit that referenced this issue Feb 15, 2017
matz added a commit that referenced this issue Feb 15, 2017
@matz
Copy link
Member

matz commented Feb 15, 2017

I made BasicObject compatible with CRuby, with two exceptions:

  • binding is not implemented for mruby
  • instance_exec which is implemented in mruby-object-ext gem and moving it to BasicObject is difficult. I don't think it's worth the price of implementation complexity.
    The SEGV issue is very interesting, but since it is a separate issue (probably) in mruby-method, it should be treated independently.

@ksss
Copy link
Contributor

ksss commented Mar 6, 2017

ksss/mruby-method side solved at 8a15abd
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants