3 ms·
I mean, recursion is just a way of saving state on the program's call stack implicitly instead of explicitly in a stack data structure. fundamentally recursion
by lsiebert 8y ago
I mean, recursion is just a way of saving state on the program's call stack implicitly instead of explicitly in a stack data structure.
fundamentally recursion is syntactical sugar over loops and stacks, as assembly can show you.
C can do recursion. It can't do first class functions, though it can pass function pointers. It just can't create new functions dynamically based on non local variables, at least not without shenanigans.
- pitched 8y agoFunctions are syntactic sugar on calls and calls are syntactic sugar on jumps so those dynamic shenanigans would be messing with calling conventions? That might not be too ridiculous.
- rustler 8y ago> fundamentally recursion is syntactical sugar over loops and stacks, as assembly can show you. That's one possible implementation of recursion on commodity hardware. Recursion itself is a mathematical method for defining a function which may not even be computable, or may be computable using other primitives.
- rs86 8y agoRecursion is not defined in terms of the execution of the program (such as storing data on the call stack). For example you can have stack less languages with recursion.