Comment by zozbot234
19 hours ago
> Ada uses two stacks allowing a callee to return a stack-allocated arrays to the caller.
You could do this manually by threading a pointer to a separately-allocated stack (could be on the heap or perhaps just a static allocation) as an extra function parameter. It's just a very simple case of arena allocation, with similar advantages and disadvantages. (For example, the caller must ensure that enough space is available on the dynamic-data stack for anything that the callee might want to push onto it.) In general it's just not really worth it, because it turns out that dynamically-sized data that one would not want to simply place on the heap is rare anyway.
No comments yet
Contribute on Hacker News ↗