DMD 0.149 release
Oskar Linde
oskar.lindeREM at OVEgmail.com
Wed Mar 8 03:11:03 PST 2006
Georg Wrede skrev:
> or the newly found "cast to bool operator", brought up by BCS (in
> D.announce 3032)
>
> a = !! strcmp("foo", "bar");
> b = !! strcmp("foo", "baf");
> c = !! strcmp("foo", "bag");
> d = !! strcmp("foo", "bad");
>
> This is certainly less typing, and it shrouds less the original code. If
> it weren't for this discovery, I'd have a *hard time* living with this
> last change in D.
>
> So the "!!" might become a much used idiom in D now. I wonder what the
> reaction from the C++ crowd will be.
I've used !! to clamp a value to {0,1} in C since ages. One advantage of
having to use !! is that the performance penalty of converting to bool
is no longer hidden. (This may not be so bad on x86 (or, setne), but may
on other architectures involve branching).
/Oskar
More information about the Digitalmars-d-announce
mailing list