3 ms·
Ah, of course. Although, gotta wonder how these stack-allocated objects interact with closures.
by matthw 17y ago
Ah, of course.
Although, gotta wonder how these stack-allocated objects interact with closures.
- dkersten 17y agoOther languages that support closures have stack allocated objects too. So its no different in this case. Maybe this wikipedia article has details: http://en.wikipedia.org/wiki/Thunk http://en.wikipedia.org/wiki/Thunk
- barrkel 17y agoC-style stack allocated objects captured by closures are not memory-safe in the absence of escape analysis. If the closure outlives the stack frame that allocated the object, a dangling pointer may occur, unless the stack frame itself is allocated on the heap, or the captured objects are moved by the compiler into a structure which is itself allocated on the heap.
- dkersten 17y agoExactly, the stack frame needs to survive with the Closure.