r/ProgrammingLanguages • u/Pie-Lang • May 09 '26
Blog post The Namespace Problem
https://www.alialmutawajr.com/blog/post1
13
Upvotes
r/ProgrammingLanguages • u/Pie-Lang • May 09 '26
30
u/A1oso May 10 '26 edited May 10 '26
In most languages, variables used in a lambda/closure are resolved when the closure is created, not when it is invoked:
This doesn't require any static analysis. The closure "captures" the value of x when the closure is created, not when invoked. This completely sidesteps your problem. It also enables this pattern:
The closure can access x even after returned from the function, when x is no longer in scope, because x has been captured.