r/functionalprogramming • u/Deonisos • Jul 19 '23
Question When does Variable Capture happen in substitution?
I want to program a compiler for uni and have to use the locally nameless representation. I just don't get the point of locally nameless. Is it just a functional programming problem or does variable capture happen in java or kotlin too?
4
Upvotes
View all comments
Show parent comment
3
u/TankorSmash Jul 20 '23
I don't know what specifically you mean by variable capture, but in terms of nested functions accidentally using the same name, that happens a lot with
i,n,response,request,data,id,diffetc.It's part of why C++'s lambda capturing is so tricky because it accidentally takes more than you expect it to. Other languages totally disable or warn for variable shadowing.