|
|
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
|
|