Today we think of the callstack as a fundamental part of the machine architecture, but at the time of algol it was still a very contentious subject. Thank You for that interesting view. Do you have a reference for the early Fortran compiler design?
I've always wondered why people say Fortran is blazing fast, even compared to C. From what I've read, Fortran's performance advantage over C is mainly due to a lack of pointer aliasing[1] which permits the compiler to optimize more aggressively. I am curious to know if modern Fortran compilers still use static allocation for local variables when compiling in Fortran 77 mode. I'd guess the cache advantages of keeping parameters close together in memory compensates for the extra work of manipulating the stack, but who knows Instead, they used self-modifying code!
To return from a subroutine call, you'd do something like this: 1. When compiling a subroutine, add a JUMP followed by an address to the end. When you call a subroutine, modify the code to change that address to point back to the callee. Jump to the subroutine. When it's done running, it hits the last JUMP and jumps back to the caller. With this, you don't need any concept of a call stack at all. I would presonally prefer the first solution you offer because though neither are portable, at least the former is clearer and more easy to code and understand.
Bush FAX: 60???? I would very much appreciate that you pointed out where it is non standard. Frankly I can't see where it is not, but I might very well be wrong. If you have a compiler and OS that don't support recursion, your only course is to recast the algorithm into an iterative form.
Often this involves setting up a stack to keep track of partially-computed intermediate results. I've seen iterative versions of Quicksort a recursive sorting algorithm , written in F77, which do this. Section Almost the same words are in I'd reverse the question. The "indirectly" in the above quote is refering to exactly the kind of construct posted.
As others have noted, this is called indirect recursion. However, noone really addressed your real problem. You write that some jobs require recursion for the coding. This is not true. There's no reason you can't CALL your own entry-point. Blorgbeard - absolutely true, although I'd argue that this is insufficient to count as "supports recursion" in the commonly understood sense as it doesn't handle the parameters needed for the recursive call.
Well, recursive calls don't technically need parameters, right? Technically, no. But being able to code one trivial case doesn't IMHO mean that you should should describe assembly as "supporting recursion".
Most practical uses of recursion require parameters. I suppose you could say that. I guess it's a matter of what you call "supporting". Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. Answer This Question. The Overflow Blog. Does ES6 make JavaScript frameworks obsolete?
Podcast Do polyglots have an edge when it comes to mastering programming Featured on Meta. Now live: A fully responsive profile. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. What properties must a language have to support recursion? Ask Question.
Asked 8 years, 9 months ago. Active 8 years, 6 months ago. Viewed 2k times. I found out that the answer was a But I want to know all the features that a programming language should have to support the recursion. Can somebody please solve my doubt Thanks in advance. Improve this question. Agreed, welcome to scicomp and thanks for the question. Just to echo everything Deer Hunter said, we have a lot of Fortran users in this community, but we generally don't handle general programming questions like this.
0コメント