3 ms·
The ancient world before computers had stacks or heaps
- accrual 3y agoWithout a stack or heap, are the pre-allocated variables essentially just stored in main memory at a fixed location? I assume if you call the same function from more than one caller, the compiler would just overwrite the return address variable for each call.
- rightbyte 3y agoWasn't ancient Fortran like that? I.e. recursive calls would use the same variables and were impossible.
- Someone 3y agoOne thing that this article doesn’t mention is that compilers could and typically would reuse the memory of all those “secret global variables”. As an easy example, leaf functions can reuse memory addresses that other leaf functions use for arguments, local variables and return addresses. It goes much further, though. Reuse can happen as soon as you can prove foo doesn’t call bar directly or indirectly and vice versa. Software libraries wasn’t really invented yet, other than as stacks of punch cards containing source code or simulated stacks of punch cards, so compilers knew the call graph of the entire program and could optimize this as hard as they could. Dynamic code loading could, of course, break that, but that wasn’t really a thing, either, in languages such as Fortran and Cobol..
- pklausler 3y agoSEGLDR worked great on the Cray-1.
- Someone 3y agoCray-1 is from 1975. That’s long after the call stack and recursion became well-known, which was at least as early as with ALGOL (Dijkstra’s “Recursive Programming” (https://ics.uci.edu/~jajones/INF102-S18/readings/07_dijkstra.pdf https://ics.uci.edu/~jajones/INF102-S18/readings/07_dijkstra...) is from 1960.) and almost universally supported (even the Intel 4004 had a call stack)
- pklausler 3y agoSEGLDR did dynamic code loading.