[lkml]   [2001]   [Aug]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [IDEA+RFC] Possible solution for min()/max() war
--- Alexander Viro <> wrote: 
> On Fri, 24 Aug 2001, Brad Chapman wrote:
> > - make everyone use the new macros (some people are thinking :P)
> >
> > - make everyone use #ifdef blocks with a config option (you think it's :P)
> >
> > - make min()/max() typeof() wrappers for a switch-style stack of comparison
> > functions which work on the various types, i.e:
> >
> > __u8 minimum = min(one, two) -> __u8 minimum = __u8_min(one, two)
> >
> > (this may be too complex and is probably :P)
> >
> > - make min()/max() inline functions, cast things to void, and use memcmp()
> > (this might almost be reasonable, but is probably also :P)
> >
> > - stay with the old-style macros (:P, :P, :P)
> >
> > What do you think, sir?
> Use different inline functions for signed and unsigned.
> Explicitly.

OK. That sounds reasonable, but do we want to do another forced
change, or do we want to hide it? That seems to be the root of the problem:
keeping the same API but making it work _right_.

> Any scheme trying to imitate polymorphism with use of cpp/
> GNU extensions/whatever is missing the point. There is _no_ common
> operation to extend on several types. Choice between signed and
> unsigned max should be explicit - they are different operations.

Well, IIRC I remember someone saying that it was legal to compare
signed/unsigned ints, if you did it in the right order. IMHO that might be
incorrect. And none of the ideas I have suggested use any fancy cpp/GNU rubbish.
The most evil-sounding thing I suggested was #4.

> Trying to hide that is C++itis of the worst kind - false
> polymorphism that hides only one thing: subtle bugs.

Ack. (IMHO) I don't like C++ either :P


Brad Chapman

Permanent e-mail:
Current e-mail:
Alternate e-mail:

Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 12:58    [W:0.250 / U:1.084 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site