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

question, dsl with method_missing and self yield #1808

Closed
kostya opened this issue Oct 23, 2015 · 3 comments
Closed

question, dsl with method_missing and self yield #1808

kostya opened this issue Oct 23, 2015 · 3 comments

Comments

@kostya
Copy link
Contributor

kostya commented Oct 23, 2015

i am trying to build dsl: http://play.crystal-lang.org/#/r/jzg
is it possible to make with self yield understand method_missing?

something like ruby instance_eval(block)

@asterite
Copy link
Member

I think we could make this work. At least it makes sense to work that way, if methods are first looked up in the with scope. However, the ends_with?('=') condition in your example will never be true because doing a = 1 is a local variable assignment, and then if you do self.a = 1, self is not bound to the with scope. That is, with ... yield is not like Ruby's instance_eval.

@kostya
Copy link
Contributor Author

kostya commented Oct 23, 2015

in ruby the same a = 1, would be local variable, but a 1 is method call

@asterite
Copy link
Member

Yes, what I meant is that there's no way to invoke a method that ends_with?('=') if you use with ... yield.

@asterite asterite added this to the 0.20.4 milestone Dec 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants