logoalt Hacker News

tsimionesculast Sunday at 4:40 PM1 replyview on HN

And what if you need to close over some local variable?


Replies

flohofwoelast Sunday at 4:45 PM

Not possible, you'll need to pass the captured variables explicitly into the 'lambda' via some sort of context parameter.

And considering the memory management magic that would need to be implemented by the compiler for 'painless capture' that's probably a good thing (e.g. there would almost certainly be a hidden heap allocation required which is a big no-no in Zig).

show 4 replies