POV-Ray : Newsgroups : povray.off-topic : Teach yourself C++ in 21 days : Re: Days 5- Server Time
29 Jul 2024 12:20:47 EDT (-0400)
  Re: Days 5-  
From: Darren New
Date: 25 Apr 2012 23:33:45
Message: <4f98c219$1@news.povray.org>
On 4/25/2012 1:22, Invisible wrote:
> Really? That's surprising. No recursive sorting algorithms for balancing the
> B*-trees that the directory nodes use, or for sorting the ready thread list
> by priority?

If you can limit the recursion a priori, then sure. If you know you'll only 
have at most 4 levels of tree, or only 128 entries in the list to sort, or 
something like that, recursion is fine. I wouldn't write production code to 
manipulate an arbitrary data structure with actual machine-stack-based 
recursion in C.

> SQL is a rather special-purpose language. I'm not sure it even /supports/
> recursion...

That's kind of my point.

> In other words, you manually implement the stack.

Yes.

> Tell me, in what way does this prevent you running out of stack?

It doesn't. It just keeps you from running out of stack without knowing it.

If your language runtime already supplies that service (e.g., C# throwing an 
exception when it runs out of stack or something) then recursive algorithms 
are fine.

>> Unless you have a CPU that actually enforces calling conventions.
> So... how is it ever possible to statically link software?

You appear to be having a hard time distinguishing "it's 
implemention-defined and not specified in the standard' from "we don't know 
what it is, ever."

> I mean, if every compiler uses its own random calling convention,

It doesn't.

> then how
> /the hell/ is it possible to write some C, link it against GMP, wxWidgets
> and the OS header files, and get a usable binary? You know, given that you
> have no idea which compiler these libraries are compiled with...

Because sometimes the OS defines the calling convention to be used.

> I would, however, expect that on any given architecture, the C calling
> convention is always the same.

In spite of the page I pointed you to showing all the different calling 
conventions used by the x86 line, right?

-- 
Darren New, San Diego CA, USA (PST)
   "Oh no! We're out of code juice!"
   "Don't panic. There's beans and filters
    in the cabinet."


Post a reply to this message

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