Closed cycomachead closed 10 years ago
Unlike BYOB Snap has a uniform scope, i.e. you can use any variable setter or getter block anywhere and it'll simply look up the value for its variable name in the current scope, so there is no need for scope contrast anymore. Is there a specific issue which you would like to address?
I've been seeing students name script variables and global var's the same name, and it can happen with block variables too. It would be nice to have the different coloring so you could tell which is which.
So, what happens when I create script variables which duplicate global variable names? Do the globals just take over? Do blocks have their own scope still?
In the case of same-named variables the nearest lexically scoped one precedes outer scopes. In your example the script var takes precedence over the others:
script vars -> parameters (if any) -> sprite local vars -> globals
make sense?
Yeah, makes sense. That sounds right.
I can't remember the example I was working through with a student today, though it was a little messy.
Though, I will say it was cool to just delete the script variables block and not need to make changes and have code run! :)
Okay, I think this has been resolved - we no longer have conflicting scopes in Snap as we used to have in BYOB - I'm closing this issue. Thanks!
Is there any plans to bring back the scope contrast function to Snap!?