Forbid dynamic arrays in boolean evaluation contexts
Steven Schveighoffer
schveiguy at yahoo.com
Mon Mar 25 08:29:24 PDT 2013
On Mon, 25 Mar 2013 11:04:58 -0400, bearophile <bearophileHUGS at lycos.com>
wrote:
> Steven Schveighoffer:
>
>> I would favor just changing the behavior.
>
> If you just change the behavior, then I suggest to take in account
> associative arrays too:
>
>
> void main() {
> bool[int] aa;
> assert(!aa);
> aa = [1: true];
> assert(aa);
> aa.remove(1);
> assert(aa);
> assert(!aa.length);
> }
This can be done without compiler changes. Just define opCast!bool for
AssocArray (or whatever the template is, I can't remember).
I do agree this should be done too.
-Steve
More information about the Digitalmars-d
mailing list