Timeline for Why does saving addresses on a stack give us the only way out for both nesting and "recursing" subroutines? [closed]
Current License: CC BY-SA 4.0
18 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Feb 19 at 10:33 | comment | added | Russell McMahon♦ | @DoxyLover Thanks for saying that you were close-voting and why. I consider that it greatly helps understanding when people do this. | |
Feb 19 at 10:31 | comment | added | Russell McMahon♦ | @EE18 Recursion is essentially defined as "tail eating". A routine calls itself repeatedly until some aim is left and then either unwinds, which progressively frees up resources acquired along the way, or abandons ship and leaves the system to reacquire the abandoned resources. In a case where abandoning ship at the end of the process is acceptable then non-stack memory may well be acceptable as you are never going back. | |
Feb 17 at 18:57 | vote | accept | EE18 | ||
Feb 17 at 16:50 | history | left closed in review |
toolic Voltage Spike♦ |
Original close reason(s) were not resolved | |
Feb 17 at 16:23 | comment | added | EE18 | Thanks for the helpful comment @RussellMcMahon I think what I was missing was how specifically the tail eating comes about, and why it can't be avoided. Periblepsis gives a very nice answer below showing an example in which the tail does get eaten and I suppose I'll have to satisfy myself that no one has come up with a way of not having the tail eaten! | |
Feb 17 at 15:33 | review | Reopen votes | |||
Feb 17 at 16:50 | |||||
Feb 17 at 14:14 | history | edited | brhans | CC BY-SA 4.0 |
fix formatting
|
Feb 17 at 6:27 | comment | added | Russell McMahon♦ | @periblepsis says. Recursion eats its own tail from the same location and then unwinds. On every loop it needs a new store location.Which is what a stack does. | |
Feb 17 at 5:33 | history | closed |
DoxyLover ocrdu Voltage Spike♦ |
Not suitable for this site | |
Feb 17 at 5:24 | history | edited | EE18 | CC BY-SA 4.0 |
deleted 3 characters in body
|
Feb 17 at 5:10 | comment | added | EE18 | Done, my bad! @internet | |
Feb 17 at 5:10 | history | edited | EE18 | CC BY-SA 4.0 |
added 74 characters in body
|
Feb 17 at 5:00 | comment | added | internet | Please add the source of the text you quoted. | |
Feb 17 at 4:26 | review | Close votes | |||
Feb 17 at 5:34 | |||||
Feb 17 at 4:11 | comment | added | EE18 | Ah, my bad. I thought maybe architecture/ISA-level questions were OK but if not I will move it over? @DoxyLover Just to be clear, this is not a question about assembly programming but about architecture decisions around how subroutines ought to return. | |
Feb 17 at 4:08 | comment | added | DoxyLover | I’m voting to close this question because this is a general programming question, not electrical engineering. It probably belongs on StackOverflow. | |
Feb 17 at 3:59 | answer | added | periblepsis | timeline score: 1 | |
Feb 17 at 3:47 | history | asked | EE18 | CC BY-SA 4.0 |