On Sunday, 27 July 2014 at 20:20:54 UTC, Walter Bright wrote:
On 7/27/2014 6:52 AM, bearophile wrote:
A possible piece of the solution is the recently suggested
__trait(valueRange,
exp), but alone that's not enough.
Instead of adding more language features, purpose existing ones:
assert(exp >= min && exp <= max);
To what extent can a compiler use assertions? Can it work
backwards from an assert to affect previous code?
void foo(int a)
{
enforce(a & 1);
assert(a & 1);
}
void bar()
{
assert(a & 1);
enforce(a & 1);
}
Which, if either, of those calls to enforce can be removed?