On Monday, 20 August 2012 at 09:58:54 UTC, Jonathan M Davis wrote:
I'm not sure that it was ever even considered that the
programmer might want
to do something special with them. assert is affected by
-release, and -
noboundscheck was added later for extra control. They had
nothing to do with
the programmer doing anything in their code. I have no idea how
Walter would
feel about adding noboundscheck and/or release versions which
correspond to
the flags.
But since it's generally bad practice to make code differ
between non-release
mode and release mode, and assert already gives you the ability
to have checks
that which are around in non-release but not in release, I
don't know that it
really buys you much to add such version identifiers.
- Jonathan M Davis
C++ uses "ifdef debug" a lot, so I guess it is confusing at
first, but "assert" can indeed get the same done (worst case
scenario, it can call a function with side effects that always
returns true). There is no equivalent for "ifndef debug", but I
agree that is bad.
Regarding "noboundscheck" I was thinking in particular about
Container.Array, or any other range in general. If the user
compiles using noboundscheck, then one can only assume the user
does not want for Container.Array.Range to check its own bounds
either.
Andrei says something in his book along the lines of "If a built
in can do it, so should a user defined type" (don't have the
quote here though, sorry). So basically, if a built in array can
conditionally control bounds checking, why can't a user defined
range do it?