assert semantic change proposal
John Carter via Digitalmars-d
digitalmars-d at puremagic.com
Sun Aug 3 14:57:06 PDT 2014
On Sunday, 3 August 2014 at 19:47:27 UTC, David Bregman wrote:
> Walter has proposed a change to D's assert function as follows
> [1]:
> "The compiler can make use of assert expressions to improve
> optimization, even in -release mode."
Hmm. I really really do like that idea.
I suspect it is one of those ideas of Walter's that has
consequences that reach further than anyone foresees..... but
that's OK, because it is fundamentally the correct course of
action, it's implications foreseen and unforeseen will be correct.
One "near term" implication is to permit deeper static checking
of the code.
Both in terms of "Well, actually there is a code path in which
the assert expression could be false, flag it with a warning" and
in terms of "There is a code path which is unused / incorrect /
erroneous is the assert expression is true", flag as an
error/warning.
Furthermore, in the presence of the deeper compile time function
evaluation, I suspect we will get deeper and even more suprising
consequences from this decision.
Suddenly we have, at compile time, an expression we know to be
true, always, at run time. Thus where possible, the compiler can
infer as much as it can from this.
The implications of that will be very very interesting and far
reaching.
As I said, this choice will have very far reaching and unforeseen
and unforeseeable consequences.... but that's OK, since it is
fundamentally the correct choice, those consequences will be
correct too.
More information about the Digitalmars-d
mailing list