views:

168

answers:

3

does some language or platform not have a fixed size of stack and therefore not easy to overflow? I remember using C on UNIX, the stack was difficult to overflow while back in the days of Win 3.1, the stack was very easy to overflow.

+1  A: 

this is a question of the practical vs the theoretical. the stack of a lisp interpreter is limited only by available memory

in scheme and other languages that implement tail recursion, a tail recursive function would have an infinite stack

jottos
A tail recursive function with the associated iterative optimization doesn't even go on the stack, as far as I know. If you define "stack" as related to calling functions, as an abstraction, that statement is true, but I wouldn't use that abstraction, since it's not particularly helpful. I didn't get the impression that that definition was normal, either.
Devin Jeanpierre
can't C on UNIX / Solaris also have a stack size limited only by the physical memory?
動靜能量
I recall C had/has a stack segment size that is a kernel param
jottos
Devin, good question about whether a tail recursive function would use a stack. I implemented a scheme interpreter and yes, there is a stack frame. The difference is in the return action, with a tail recursive function there is a tail-return which overwrites the existing frame, so the stack used by that function has only a single frame.
jottos
+1  A: 

If by "stack" you mean any old stack, most languages do-- Java has a stack class limited only by memory. More likely you mean the call stack, in which case the biggest example I can think of is Stackless Python, which, to my understanding, uses a pure-python memory-limited stack (like Java's) as the call stack for Python code, rather than using C's call stack.

Devin Jeanpierre
A: 

Mac Systems 6, 7, and 8 had call stacks that could grow without artificial limit.

It also has no guaranteed way to detect a stack--heap collision, and could get you into all kinds of trouble that way...

dmckee