wdte
wdte copied to clipboard
wdte: arrays don't keep track of frames and don't evaluate elements down to values
If an array is returned by a function and the elements of the array reference the arguments of that function, then the array is unusable. For example,
'stream' => s;
'io' => io;
example a => [a];
main => s.new (example 3) -> s.map (io.writeln io.stdout) -> s.drain;
will panic.
Similarly, an array containing unevaluated elements may not work as intended. For example,
'io' => io;
example a => [a];
main => io.write io.stdout (example 3);
will print [<address of a>], not [3].
Possible solution: Make arrays evaluate their elements when evaluated, returning an array of the evaluated elements. A quick test showed that this solves both problems. The big issue is that it's potentially inefficient and may have unintended side-effects. I'll probably go with this for now and then leave this issue open while looking for another solution.