evhub / coconut

Simple, elegant, Pythonic functional programming.
http://coconut-lang.org
Apache License 2.0
4.04k stars 120 forks source link

Fix scoping for statement lambdas #814

Closed evhub closed 6 months ago

evhub commented 8 months ago

Statement lambdas should automatically get partially applied with the surrounding scope, even that introduced by a list comprehension or normal lambda. Easy way to do this is try to inject locals(), hard way is to detect all the local assignments and explicitly partially apply them.

evhub commented 6 months ago

This is also going to involve a change to statement lambda scoping such that it will automatically copy the value of variables introduced in expressions (lambdas and comprehensions). copyclosure will still be needed to copy everything.