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

Zajal method visibility in Sketch classes #68

Open
nasser opened this issue Oct 20, 2012 · 2 comments
Open

Zajal method visibility in Sketch classes #68

nasser opened this issue Oct 20, 2012 · 2 comments

Comments

@nasser
Copy link
Owner

nasser commented Oct 20, 2012

Zajal's modules get included into the Sketch class here lib/core/sketch.rb. This is beneficial and avoids namespace pollution, but breaks code like this

class Particle
  def draw
    # Particle can't see Graphics#cirlcle, because Graphics wasn't included into it
    circle @x, @y, 20 
  end
end

draw do
  p = Particle.new
  p.draw
end
@nasser
Copy link
Owner Author

nasser commented Oct 20, 2012

I'm not 100% sure how to tackle this. Any ideas, @judy?

@judy-zz
Copy link

judy-zz commented Oct 26, 2012

I did some research, but I haven't found anything yet. I'd love to see if there's a way to overwrite Class generation, so each time a Class is defined, we automatically define #method_missing. So if a user writes circle, and it's not defined in the class, our method_missing picks up on it, and is able to defer it to Graphics if possible. Not sure.

Otherwise, we'll just have to communicate that you need to include Graphics if you're doing graphics in your class.

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

2 participants