My Kingdom For ...

Matti Niemenmaa see_signature at for.real.address
Thu Feb 21 10:02:08 PST 2008


Gregor Richards wrote:
> /me boos !in again.
> 
> Walter's argument against !in makes perfect sense, and nobody ever 
> acknowledges that. 'in' is not a boolean operation, and it wouldn't be 
> good for 'in' to return a pointer and '!in' to return a bool. That's 
> just silly.

Why not make it generic? I hereby propose that "a !op b" be always equivalent to 
"(a op b) !is cast(typeof(a op b))0". (Not just "!(a op b)" because I'm not sure 
whether that works in all cases, but I think this should.)

Imagine the increased clarity:

return *a !- *b ? *a!**b : foo!(int)!&a;

Compare this to the ludicrously verbose:

return *a - *b == 0 ? *a * *b == 0 : (foo!(int) & a) !is null;

We even sidestep the problem of "a & b == 0" being parsed as "a & (b == 0)"!

-- 
E-mail address: matti.niemenmaa+news, domain is iki (DOT) fi



More information about the Digitalmars-d mailing list