-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
Removing g
from the list of py5 "reserved words" breaks things
#317
Comments
Ideally, if you could rename g to graphics but leave a garden variety global variable g that points to the graphics named object that would get the best of both worlds wouldn't it? I mean one could override g with attribution and still have it for retro-compatibiity. Too much complexity? |
That's a nice idea for compatibility but it won't work. The same issue above would still occur. Here's a more compatibility-friendly alternative: add I'm fine with either way, but note that py5 is still labeled as "alpha" software, and these kinds of changes are allowed. I forget exactly what all the rules are for "alpha", "beta", etc. but I remember this part. :) I have been thinking about moving py5 from alpha to beta though...getting closer to the point where it makes sense to do that. The above alternative is a better practice for non-alpha libraries. Edit: after thinking about it for a bit, this deprecation warning alternative is the better way to go. I am sure this change will break someone's code and I don't want frustrated people wasting time debugging what will seem to them to be a confusing problem. |
I'll go with your decision, but I don't understand why we can't have something like I suppose mine is the mindset of the small script/sketch builder who can hack "ad hoc" names in the global namespace, not the mindset of the library builder. |
Hmmm, let me look into that. I just typed out an explanation about why it can't be like that because of how imported mode works, but then I realized it might work after all. Let me do some investigation and see. |
After thinking about the new name, maybe |
Well, py5 already has |
OK, I sat down to figure this out and it seems I would need to add too many hacks to the code for this to work. Adding the equivalent of Allowing the variable However, while investigating this, I noticed that there already is a With this plan, |
Behold Let's add to our notes we'll have to update the docs:
|
It had a good run! In all seriousness,
I added a deprecation note to http://dev.py5coding.org/reference/sketch_g.html That is the dev website which contains everything that will be on the production site once the release goes live. I didn't think to remove Are you suggesting that we leave |
I removed this but opened #322 to track the final removal from py5. |
I can define a variable named
g
but I can't actually use it. Simple example:result:
I don't know why I didn't find this problem before. I guess when I tested it I only tested I could create a variable named
g
but didn't use it for anything.I agree with @villares 's logic of allowing
g
as a variable name because single character reserved words are problematic. However, this configuration isn't going to work.The solution is to rename
g
to something else, such asgraphics
. The new name will become a reserved word. @villares, are you ok with renamingg
tographics
and making it a reserved word? Any other name suggestions?The text was updated successfully, but these errors were encountered: