POV-Ray : Newsgroups : povray.off-topic : Curious C / C++ defined behavior question : Partially agree Server Time
30 Jul 2024 00:23:06 EDT (-0400)
  Partially agree  
From: Lars R 
Date: 30 Jun 2011 03:54:43
Message: <4e0c2bc3$1@news.povray.org>
On 06/29/11 18:49, Darren New wrote:
> On 6/29/2011 0:44, Lars R. wrote:
>> I'd suggest something like “A recursion depth of at least 5 must be
>> supported by the platform. The actual limit might be higher and can be
>> determined by ...”
> 
> Well, it's not even *recursion* depth, but just call stack depth.

If a language allows recursion you need some kind of stack. If a
language only allows non-recursive function calls you can hold the local
variables at fix addresses, as you also wrote below.

Some tricks like tail recursion optimization allows such fix addresses
also for a limited kind of recursive functions, though...

>> But such guarantee is not easily definable because the size of the
>> function parameters is not limited (only their number).
> 
> Not any more. In the original version of C, you couldn't pass structs by
> value, so it would have been easier to figure out how big your arguments
> are.

Outdated non-standard versions don't interest me. ^^

>> But statements like “Every function call might fail due to reasons that
>> are out of scope of this standard“ are also not sensible, I think.
> 
> I think you could require a minimum amount of stack space to be
> available, if you wanted.

If you require that (non-recursive) function calls use a "stack" at all.
That's why both the C and C++ standards avoid to use the term "stack" in
this context.

> The standard could guarantee that the number
> of bytes of auto and parameter values passed not exceeding a particular
> value could be specified, if they wanted.

Sounds better. So it doesn't matter whether parameters are passed on
some kind of "stack" (in memory or CPU registers) or on fixed locations
(im memory or fixed CPU registers).


		Lars R.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.