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

Try Binding class #3468

Merged
merged 1 commit into from Feb 25, 2021
Merged

Try Binding class #3468

merged 1 commit into from Feb 25, 2021

Conversation

ksss
Copy link
Contributor

@ksss ksss commented Feb 25, 2017

I'm trying to implement CRuby's Binding class.
Binding#local_variables is easy.
But I couldn't implement Binding#eval because it's too difficult.
It failed in this case.

class A
  class << self
    def b
      @a = 42
      b = 'local_variable'
      binding
    end
  end
end
p A.b.eval("[@a, b]")
# Expect: [42, "local_variable"]
# Actual(This branch): [42, []]

Does anyone have a good idea?

@take-cheeze
Copy link
Contributor

Maybe recording the struct RProc* and pc of the previous stack frame could save the binding.

@dearblue
Copy link
Contributor

@ksss, by saving the REnv object, the tests contained in your pull request will pass.
https://github.com/dearblue/mruby/tree/binding
This working branch is now the mruby HEAD (07224f8).
Is it possible for you to continue the work you are planning?

@ksss
Copy link
Contributor Author

ksss commented Oct 25, 2020

@dearblue Hi.
Thank you for finding this PR.
But I've forgotten what this PR is all about and I have no motivation to continue with it.
I'm glad. If you will take over this project.

@dearblue
Copy link
Contributor

I see.
Perhaps there are some parts that can not be implemented due to mruby restrictions, but I will issue a new pull request someday by adding methods that are lacking compared to CRuby.
Thank you for your reply.

@dearblue dearblue mentioned this pull request Feb 22, 2021
@dearblue
Copy link
Contributor

I have implemented anything but Binding#irb and created a pull request as #5362.
If you have any concerns, please ask them there.

@matz matz merged commit 297c5ac into mruby:master Feb 25, 2021
@ksss ksss deleted the binding branch February 26, 2021 01:44
@ksss
Copy link
Contributor Author

ksss commented Feb 26, 2021

@dearblue Great Job!!!! 🎉

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

Successfully merging this pull request may close these issues.

None yet

4 participants