[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:
> > > > 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_.
> Existing API is wrong. "Hiding" is precisely what's wrong here - we
> use the same name for two subtly different functions.

Mr. Viro,

OK. The existing API is wrong and the new min()/max() macros are the
right way to properly compare values. However, we could always add a config
option to enable a compatibility macro, which would use typeof() on one of the
two variables and then call the real min()/max(). Something like this (just an

#define proper_min(t, a, b) ((t)(a) < (t)(b) ? (a) : (b))
#define proper_max(t, a, b) ((t)(a) > (t)(b) ? (a) : (b))
#define min(a, b) proper_min(typeof(a), a, b)
#define max(a, b) proper_max(typeof(a), a, b)
#define min(t, a, b) ((t)(a) < (t)(b) ? (a) : (b))
#define max(t, a, b) ((t)(a) < (t)(b) ? (a) : (b))

Unfortunately, this would violate your idea that "hiding" the real
code behind compatibility stuff is C++esque, and, IYO, an Evil Thing(tm). That
just leaves me with one question to everybody:

<rant type="question" intensity="30%">
Why did Linus change this out of /dev/null and suddenly run off!?


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:1.065 / U:0.920 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site