string <-> null/bool implicit conversion

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Thu Aug 20 13:39:00 PDT 2015


On 08/20/2015 10:26 PM, David Nadlinger wrote:
> On Thursday, 20 August 2015 at 16:45:18 UTC, Márcio Martins wrote:
>> Having 2 empty strings evaluate differently is very unintuitive and
>> error-prone, in my opinion.
>
> It's even worse: http://dpaste.dzfl.pl/ba3376feca8e
>
> The arrays are equal, but their Boolean value is not.
>
> I don't get how Andrei can reconcile this with his "D avoids unforced
> errors" stance.
>
>   — David

By denying that it is an error and by playing down its significance, IIRC.
Same about [] is null, [1][1..1] is null, but {auto a=[1]; return 
a[1..1];}() !is null and related cases.


More information about the Digitalmars-d mailing list