Chris Tutty wrote:
> All compilers have this sort of issue, however - the example
> that always amazed me was that Visual Studio (prior to .NET)
> treated an assignment within an if statement as a level four warning
> and, by default, only reported up to level three (or the other
> way around). Who-ever decided that an assignment within an
> if statement was more likely to be a deliberate decision than a
> missing equals needed taking out back for a good kicking.
Well, there is always the situation where a function returns zero
for success and one of several non-zero codes for failure, which
leads to a pretty standard idiom:
if (result = ElephantTrick())
{
switch (result)
{
case 1:
fprintf (stderr, "elephants need more peanuts\n");
break;
case 2:
fprintf (stderr, "elephants have forgotten what to do\n");
break;
default:
fprintf (stderr, "um, nobody knows what went wrong\n");
break;
}
}
Back in the days of 24x80 text displays, people tried to cram as much
onto each line as possible, so that kind of thing was common, and
there's probably still lots of code that has that kind of thing in it.
- Logan
--
For information on using the Palm Developer Forums, or to unsubscribe, please
see http://www.palmos.com/dev/support/forums/