Re:The MIN Challenge
by iano on Sunday June 15, 2014 @06:00PM
(#7896485)
Not entirely related to the post, but what's the sane use case for doing:
like in the first example? I cannot think of a good reason to do this.
[ Parent
| on HN ]
It may not be a good reason to do this, but you can condense
if (failure) {
errno = EINVAL;
return -1;
}
into if (failure)
return (errno = EINVAL, -1);In any sane code, you'd have the open and close brackets anyways, so all this code does is trade a few '\n' characters for a few parentheses characters. I'd opt for the former still.
Re:The MIN Challenge
by eatnumber1 on Sunday June 15, 2014 @06:15PM
(#7896521)
If the min macro would have worked, it would have allowed the two lines
min(1, 2, out);
return out;
to be condensed into one line.I know this mainly as a useful macro implementation trick if where you want to be able to use it in an expression.