lambda-calculus icon indicating copy to clipboard operation
lambda-calculus copied to clipboard

Replace `Env` implementation with functions

Open JohanWiltink opened this issue 3 years ago • 2 comments

The current Env is already opaque. It might turn out implementing environments with functions is faster, because copying is faster and sharing is improved. If so, we lose nothing by switching.

I'm not saying the current implementation is ideal - it would be good to be able to look into an environment and see actual values. But I have no ideas how to allow for call by need and have them be transparent and memory efficient.

JohanWiltink avatar Feb 06 '22 02:02 JohanWiltink

In heavily recursive scenarios, env as Function might leave a long tail of shadowed bindings that can not be garbage-collected, where env as Map keeps the current size down to a limited set of actually reachable bindings.

env as Function might not actually be an improvement, because it reintroduces recursion ( limits ) into evaluation.

JohanWiltink avatar Feb 14 '22 19:02 JohanWiltink

Can always pass a thunk into an environment, tag it as unevaluated, and have retrieval take into account that tag.

That might allow for transparency on variables.

JohanWiltink avatar Feb 19 '22 15:02 JohanWiltink