Forbid dynamic arrays in boolean evaluation contexts
bearophile
bearophileHUGS at lycos.com
Mon Mar 25 15:49:38 PDT 2013
Vladimir Panteleev:
> That would silently break my code.
Right, that's why I have asked to just forbid something. The
proposal is a little breaking change either way, but turning
something into an error allows you to find it quickly in most
cases. (But D also has the compiles __trait, that does not give
an error, it just silently returns false instead of true).
On the other hand the behaviour change is not meant to happen all
at once. It has to be a warning, then deprecation and then a
change, along months and three or more DMD versions. So there is
time to fix D code. And even if the old D code doesn't get
changed, I think it's uncommon for code to rely on dynamic array
to be actually (null,null) instead of being of zero length. So
the total amount of breakage even for a semantic change is
probably small. Considering the presence of the compiles __trait,
the idea of the small behaviour change is not so bad.
So far this proposal was well received (almost everyone in the
thread seems to agree to change the current behaviour. But some
persons prefer to change it into an error, while others prefer a
more handy semantics change. In both cases the change path will
start at the same way: warning, deprecation, and then an error or
a behavour change). This proposal is one of the about fifteen
tiny D breaking changes that I am suggesting since years.
If Andrei Alexandrescu or Walter are reading this thread I'd like
a comment on this very small proposal mostly meant to avoid
certain bugs.
Bye,
bearophile
More information about the Digitalmars-d
mailing list