POV-Ray : Newsgroups : povray.off-topic : Computer language quirks : Computer language quirks Server Time
29 Jul 2024 20:25:10 EDT (-0400)
  Computer language quirks  
From: Darren New
Date: 2 May 2011 13:26:39
Message: <4dbee94f$1@news.povray.org>
I find it mildly distracting that I can't do this:

void xyz() { ... }

void abc()
{
     if (...)
        return xyz();
     else blah blah blah;
}

I can do it if xyz and abc return values, but not if they don't. I have to 
instead
      if (...)
      {
         xyz();
         return;
      }

which significantly expands a function that has lots of such dispatches. It 
also makes it unclear to the casual reader that this is a tail call.


Also, I realized I tend to have larger functions than necessary because most 
languages I'm using don't let me nest functions.  For example, I have an 
output list, two error bars, and a point. I want to add the point (or a few) 
to the list if it's within the two error bars.  I do this several times.

In Pascal or Ada or something, I could do something ilke
     MaybeAddPoint(x, y);
as the call, and MaybeAddPoint being nested would let it access the other 
locals. But in C or C# or Java, I have to do
     MaybeAddPoint(x, y, errlo, errhi, output);
where errlo, errhi, and output are the same value for every call of the 
function.  Hence, when it's only two or three calls, with lots of those 
kinds of constant-for-all-calls arguments, I find I sometimes wind up 
inlining the stuff, because that's just as clear as passing half a dozen 
"parameters" that aren't really parameters at all, but rather the 
environment they're working in.

-- 
Darren New, San Diego CA, USA (PST)
   "Coding without comments is like
    driving without turn signals."


Post a reply to this message

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