On Sunday, 4 March 2018 at 00:32:20 UTC, Walter Bright wrote:
On 4/12/2017 4:25 AM, Mike Parker wrote:
DIP 1006 is titled "Providing more selective control over
contracts".
https://github.com/dlang/DIPs/blob/master/DIPs/DIP1006.md
Currently, we have 3 switches that affect the asserts:
`release`, `boundscheck`, and `unittest`. The documentation for
these new additions is completely confusing. No mention is made
of interactions with the latter two. No mention is made on what
happens if more than one of these switches is used, or what if
the same switch appears multiple times.
I'd like to see a chart enumerating all the behaviors
influenced by these switches, the default behavior, and which
switch settings do what.
Each switch, when applied, should specify what happens to each
behavior:
1. turned on
2. turned off
3. not affected
and that the switches are applied in the order they appear on
the command line.
The use of comma-separated arguments is something I've argued
against for other switches. The use of `-release=in
-release=out` should be fine and is less confusing/buggy to
implement.
Why? Implementation is trivial (unit testable no less!) , see
https://github.com/dlang/dmd/pull/7863 and extensible to other
args.
The idea that `-release=in` actually turns *off* `in` is
completely topsy-turvy.
Ideally, the whole thing should be simplified to its
fundamentals:
1. leave the old switches as they are
2. Add a new switch, let's say "check":
-check turn on all checks
-check=on turn on all checks
-check=off turn off all checks
-check=xxx turn on check xxx
-check=yyy turn on check yyy
simple, easy to explain, easy to comprehend, easy to implement,
easy to extend with new checks.
I think aggregation is a good idea. So is phrasing in the
positive sense, except for it looks like xxx and yyy are _off_ by
default, where surely we want all checks _on_ by default.