EDIT: condensed the most important and relevant bits since it got confusing, and many proposals changed
an "object" here is a stage, sprite, or procedure. they all have variables, can be put in the OF block, and be told to do things with TELL and ASK. bh says this naming is correct.
-
change the OBJECT [ v] block to return procedures put in. this is extremely unlikely to break projects and is more consistent with actual groupings. either that, or change the name to something that means "sprite or stage" (although i'm not sure what that would be called)
-
a properly supported way to create a procedure or other object with no variables (not even globals). currently you can do this with JOIN procedure, but the behavior will apparently change later to include globals. libraries can't decide globals or sprite variables, so it's most important for them, and it can't just be ignored due to the [variables v] OF block.
i suggest making it possible with (procedure) OF [none v] and OF [global v] where none has no variables, and global only includes globals. -
i'm not very sure about this suggestion now (it would probably be difficult to implement), but it would also be useful to have a way to inherit variables from multiple places. it's possible to inherit variables from one place and create extra script variables (use the context of one procedure, create some script variables, and return another one), but there isn't a way of inheriting from two unrelated places. copying the variables doesn't share them like inheriting does.
original post (mostly), has some worse suggestions
related somewhat to [this](https://forum.snap.berkeley.edu/t/variable-scoping-issues-on-joined-blocks/12390), but with more edge cases. sorry this is probably too long not sure if these are possible or not, but i'm pretty sure they aren't or would be extremely weird hacksi can't find a nice way to unbind a lambda, running ((lambda) of [ v]) just returns nothing, when i would expect it to give a lambda with no variables attached. splitting and joining would work, but i assume that has a large overhead, and joining by itself messes up the function.
EDIT: ((lambda) of (join (RING WITH SOMETHING IN IT))) works, but is inelegant. i think ((lambda) of [ v]) should work
i can get the variable names and values from a function, but not a scope that can be placed onto other functions.
if there isn't a way to get it, i would suggest ([sprite v] of (lambda)), ([environment v] of (lambda)). and/or ((lambda) of (lambda)).
note that script local variables come with a lambda environment, so sprite might be slightly misleading unless it removes them. ((lambda) of (lambda)) feels the most logical and i think would hint better that empty lambdas could be used as variable environments.
note that this isn't about getting the current values of the variables, that can be done with (([variables v] of (lambda)) of (lambda)), the problem is that it doesn't share the variables (globals become local and such)
EDIT: this actually can be done with ((lambda) of (lambda)), i forgot to test it because it's the last possibility i thought of. i think all this needs now is documentation.
note that you can also tell a lambda to do something with the tell block
i don't see any way to append to an existing environment, the closest thing is inherit, which (i assume) has other related effects, would be very confusing to use for this purpose. i think there should be an "inherit [ v] from [ v]" block, possibly even to replace the current one (since selecting a specific sprite is easier to understand just by reading), and going off the "just by reading", it could be even more understandable as "use variable [ v] of [ v]".
a major issue with this block is that it can't actually look like what i described, since it would need to:
- show a dropdown of relevant variables like the ( of ) block
- take in variable inputs like ([variables v] of (thing)) (the ( of ) block is able to do this)
- show upvars for the input(s) given
this is the hard one! it's not even possible all of the time and would need to automatically adjust to the variable input when it can.
this is a bit of a design challenge, it's too late for me to think about this right now, and this post is already too long, so i'll stop here. and yes, i did find real use cases for all of these.