Open mattbierner opened 10 years ago
Without additional logic, function declarations mess this up because they are inited before running code (unlike vars which just create empty bindings) and capture their unique local environment.
Function declarations in functions cannot capture the source environment of their parent, but need to capture the unique copy of it used for the invocation.
One solution may be the following binding initialization for functions:
Then for each call (in forked env):
Language currently create a new environment for each invocation.
This is not necessary, the function should just construct the environment when it is declared, save this environment, and then push and bind arguments on a copy of this environment when it is called.
createArgumentsBinding
called ininitFunction
should just create placeholder bindings instead of binding the actual values.