4 ms·
I want infinite stack.
by worik 5y ago
I want infinite stack.
- rvbissell 5y agoThen make sure all your calls are in tail-call positions, and use a compiler or interpreter with TCO.
- Dylan16807 5y agoSo basically "program without subroutines" okay thanks.
- rpz 5y agoNot necessarily. I recommend checking out forth :)
- Dylan16807 5y agoI really don't know what you mean. Forth has two stacks that can grow infinitely. Trying to do everything with tail calls in Forth puts you in a position much like any other language: Okay, you can have a single overarching state machine with top-level routines, but you can't factor anything into subroutines because there's no way to 'return'.
- worik 5y agoI want Forth. Progress: Fifth Eventually N!
- Dylan16807 5y agohttps://www.frathwiki.com/Fith https://www.frathwiki.com/Fith
- IshKebab 5y agoAs I understand it the stack size limit is because a process's threads share the same address spaces so basically where would you put all their stacks? With one stack you just start it from the top of (virtual) memory and put the heap at the bottom and when they meet you've run out of memory. Infinite stack! But with lots of threads there aren't enough spaces for them to start from. At least on 32-bit. On 64-bit I think you could have effectively infinite stack, or at least very very large (like 1 GB) stacks. But as far as I know nobody has bothered to do it. I guess an alternative solution would be to put the stacks in different address spaces somehow, but that could get very complicated (now you have two kinds of pointers). Are there any old systems that had separate heap and stack address spaces?
- abecedarius 5y agoI basically never want threads. (Processes can share some of their memory in a more limited way if they need to.) I often want stack allocation without having to worry if it hits some arbitrary limit unrelated to actual memory available. Memory is fungible. It's true that there are programmers with different values.
- mrjin 5y agoStack was really meant to save parameters for function calls and local variables for functions or in your terms sub-routines. In a well organized program, usually you would not need much stack space unless there was something went wrong, such as a recursive call without termination condition etc..
- feb 5y agoEven local variables of functions can take up a lot of room can take quite a lot of space. Especially when you minimize use of the heap. Using the stack instead of heap where possible makes for clean automatic free-ing of unused memory.
- IshKebab 5y ago> In a well organized program, usually you would not need much stack space But that's only because stack space is currently limited. If stack space were as unlimited as heap space then there would be absolutely nothing wrong with using as much stack space as you wanted. It would be better even - stack space is much quicker to allocate and free than heap space.