On Sunday, 3 August 2014 at 23:24:08 UTC, Martin Krejcirik wrote:
On 3.8.2014 21:47, 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."
Couldn't this new assert behaviour be introduced as a new
optimization
switch ? Say -Oassert ? It would be off by default and would
work both
in debug and release mode.
That would be an improvement over the current proposal in my
opinion, but I see some issues. One is the general argument
against more compiler switches: complexity, and people will
always enable stuff that seems like it might give the fastest
code. Another is how do you mix and match code which is meant to
be compiled with or without the switch? I suppose it could also
be used in complement to a new function that has the proposed
behavior regardless of switches.
Regardless, it goes to show there exists a design space of
possible alternatives to the proposal.