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

Remove global pollution of bonsai #202

Open
wolframkriesing opened this issue Mar 7, 2013 · 4 comments
Open

Remove global pollution of bonsai #202

wolframkriesing opened this issue Mar 7, 2013 · 4 comments

Comments

@wolframkriesing
Copy link
Member

currently bonsai's (worker and/or iframe) context is polluted with all bonsai classes, such as Shape, Movie, etc. imho this is a possible trap for users that start working in that context too. The first use case, we stumbled over, was plugins, that do also write into that namespace. If the use of that context grows, which would make sense, since workload is "threaded" this way, this will become a problem, jquery-plugins like :).

Here is a suggestion how to fix that:

  1. in the next version (lets say 0.5)
  • remove all global's
  • provide a function such as bonsai.makeAllGlobal(), which allows in a one liner to "fix" existing code after an upgrade to 0.5
  • mark global usage as deprectated
  1. in version 0.6 remove the function makeAllGlobal() completely, to become clean.
    alternatively it can be provided as a plugin, which should never be recommended, but would still exist, but never be part of "official" bonsai
@nonken
Copy link
Contributor

nonken commented Mar 7, 2013

Will this mean that we can't do things like this anymore:

new Shape()

and it would become

new bonsai.Shape()

?

@wolframkriesing
Copy link
Member Author

exactly

@nonken
Copy link
Contributor

nonken commented Mar 7, 2013

I would have a small tear in my eye because we'll loose some of the ease of use of the api but just the amount of times I hit confusion when building a small demo doing stuff like following should be reason enough to require lightweight namespaces :)

var circle = new Circle() // and now what, you'll start confusing bonsai api with your own code very soon

@wolframkriesing
Copy link
Member Author

the above is a good example. in simple scripts one might oversee where things come from.
the pollution of the "global" should make it better for future issues and real bug finding

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

2 participants