lkml.org 
[lkml]   [2001]   [Aug]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [IDEA+RFC] Possible solution for min()/max() war
--- Alexander Viro <viro@math.psu.edu> 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
example):

#ifdef CONFIG_ALLOW_COMPAT_MINMAX
#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)
#else
#define min(t, a, b) ((t)(a) < (t)(b) ? (a) : (b))
#define max(t, a, b) ((t)(a) < (t)(b) ? (a) : (b))
#endif

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!?
</rant>

Brad


=====
Brad Chapman

Permanent e-mail: kakadu_croc@yahoo.com
Current e-mail: kakadu@adelphia.net
Alternate e-mail: kakadu@netscape.net

__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

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