On Wed, Apr 24, 2013 at 2:14 PM,  <random...@fastmail.us> wrote:
> On Wed, Apr 24, 2013, at 15:32, Kent Overstreet wrote:
>> I switched to gnu99 for typeof() - it makes it possible to write min
>> and max macros that don't evaluate their arguments twice, and IMO is a
>> very worthwhile extension.
>
> Wait, you switched _to_ gnu99? For _that_?

Yep.

> A) Why do min and max need to be macros at all? Also, where do you call
> them on anything that's not an int?
> B) Where do you call them on anything that has side effects (i.e. that
> _needs_ to not be evaluated twice)?

Honestly, I don't really care to bikeshed over this - but, making
function or a macro that did evaluate its arguments twice would a) be
_inviting_ bugs, tripping people up who are used to correctly
implemented min() and max() elsewhere, and b) these versions are
relatively standard (the Linux kernel, and it's one of the things the
kernel gets right, IMO).

If people are actually using compilers that don't support typeof, I'll
just rip out all the min and max usage - better that than doing it
wrong.

Oh, it's not just min and max that use typeof, swap() too (and I think
I use swap more).

Reply via email to