This is an automated archive made by the Lemmit Bot.

The original was posted on /r/programminglanguages by /u/Lucrecious on 2024-11-12 14:08:49+00:00.


i was reading the odin language spec and found this snippet:

Odin only has non-capturing lambda procedures. For closures to work correctly would require a form of automatic memory management which will never be implemented into Odin.

i’m wondering why this is the case?

the compiler knows which variables will be used inside a lambda, and can allocate memory on the actual closure to store them.

when the user doesn’t need the closure anymore, they can use manual memory management to free it, no? same as any other memory allocated thing.

this would imply two different types of “functions” of course, a closure and a procedure, where maybe only procedures can implicitly cast to closures (procedures are just non-capturing closures).

this seems doable with manual memory management, no need for reference counting, or anything.

can someone explain if i am missing something?