Oh, how I wish that JS had something like obj.$env.identifiername to reference identifiers from the lexical scope in which an object was originally defined
@pinoaffe Objects already capture their lexical scope upon creation. I'm unsure if there's code analysis happening to reduce the part of the scope that's retained (by identifying references).
@whreq @pinoaffe Ah, sorry, I misparsed the question, brain was occupied with something else.
You're correct that only *functions* capture their lexical scope, but aside from data-only objects (which can be treated specially and pretty much eliminate the need for such an $env feature in the first place), pretty much the only other thing that can exist on objects is functions, and so in practice "non-data objects capturing their scope" and "functions stored on objects capturing their scope" end up being approximately the same thing, differing only in implementation details.
If you wanted to be really specific you could make it func.$env.something instead, this would still address the sort of usecase I'm thinking of
@joepie91 wait so do you want all objects to capture their lexical scope upon creation? Wouldn't that cause massive memory leakage? or do you want a way to explicitly capture the lexical scope upon object creation? Or am I misunderstanding this completely?