Hacker News new | ask | show | jobs
by finnw 4738 days ago
>You could imagine a more clever implementation of lexical environments that avoids this problem. Each closure could have a dictionary containing only the variables which it actually reads and writes; the values in that dictionary would themselves be mutable cells that could be shared among the lexical environments of multiple closures.

That is basically how Lua implements closures.

https://bugzilla.mozilla.org/show_bug.cgi?id=542074