Talk:Call stack/Manipulation


 * leer; pushes a special function, the general identity function, onto the stack. This seems useless, until you remember that it gets popped off when the current function returns. This means that the current function gets repeated instead of returning to its caller, and serves as a sort of secretive recursion-based loop.
 * I might be getting that wrong. To repeat the current function wouldn't you rather need to push the address of the current function to the stack rather than an "identity function"? -- Mroman (talk) 08:41, 5 January 2016 (UTC)

Second execution primitive: 'catch-thrown'
The execution primitive I am proposing is the catch-thrown construct: catch (event): ...	throw event, value; thrown (arg): // arg == value if one was passed ...

When the event is thrown from inside the first block (even if it is thrown from several calls deeper into the stack), the stack is unwound and execution continues at the beginning of the second block and then onward. If any value is thrown along with the event itself, the second block may access that value with the argument passed to it. The catch-thrown block was inspired by the anti-pattern of trying to use the try-catch-finally construct as control flow. Not sure if this has been considered before (it probably has), but I'm just going to throw it out there.

Rdococ (talk) 22:08, 16 May 2018 (UTC)