If !in is inconsistent because of bool/pointer, then so is !

downs default_357-line at yahoo.de
Fri Feb 6 15:04:47 PST 2009


Rainer Deyke wrote:
> downs wrote:
>> This is NOT a reason against !in. In fact, this so-called
>> "inconsistency" is already present in the language. If we remember,
>> !pointer already transforms it into a boolean, so it would actually
>> be more consistent if !in changed the return type to bool.
> 
> I agree.  'a != b' is short for '!(a == b)'.  'a !is b' is short for
> '!(a in b)'.  For consistency, 'a !in b ' should be short for
> '!(a in b)'.  I'd even go so far as to say that 'a !+ b' should be short
> for '!(a + b)', although I can't think of a use for the '!+' operator.
> 
> a !<op> b == !(a <op> b): simple, consistent pattern.
> a !<op> b == !(a <op> b), but only for <op> in some limited set that
> doesn't include all operators with which you might want to use the
> pattern: less consistent; requires memorization.
> 
> 

Hmm ...

A large part of the case for !in is that you can pronounce it "a *not in* b". !+, on the other hand, would be .. what? "a not plus b? does that mean a - b? " :)



More information about the Digitalmars-d mailing list