[Issue 2065] Return value of std.file.exists() is inverted.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon May 12 14:41:48 PDT 2008


http://d.puremagic.com/issues/show_bug.cgi?id=2065





------- Comment #5 from andrei at metalanguage.com  2008-05-12 16:41 -------
(In reply to comment #4)
> On 12/05/2008, d-bugmail at puremagic.com <d-bugmail at puremagic.com> wrote:
> >  I'm having a hard time seeing how:
> >
> >  return (result == 0xFFFFFFFF) ? 0 : 1;
> >
> >  is different from:
> >
> >  return result != 0xFFFFFFFF;
> 
> It's certainly conceptually different. The first one returns an int,
> with possible values 0 and 1. The second one returns a bool with
> possible values false and true.
> 

In fact it seems the constants 0 and 1 are implicitly convertible to bool but
no other integral values, which is a nice touch. I tried this program and was
pleasantly surprised:

void main()
{
    bool a = 0;
    bool b = 1;
    bool c = 2;
}

It does not compile, but it does if you remove the definition of c. This is the
kind of smarts that I'd like to extend to inferring data ranges and signedness.


-- 



More information about the Digitalmars-d-bugs mailing list