digitalmars.D.learn - Preconditions and Postconditions - selective enable/disable
- Brother Bill (7/7) Nov 30 Can we ship our application to Production with Preconditions
- user1234 (2/9) Nov 30 Yes, see https://dlang.org/dmd-linux.html#switch-check.
- Brother Bill (18/19) Dec 01 -check=[assert|bounds|in|invariant|out|switch ][=[on|off]]
- Dejan Lekic (4/10) Dec 01 One way is to export variable named DFLAGS with those options.
Can we ship our application to Production with Preconditions enabled, but with Postconditions and Invariants disabled? If so, how to? This would allow nervous managers to still have Preconditions active in Production, with slower performance. After 3 months of it "just working", they can disable the Preconditions for better performance.
Nov 30
On Monday, 1 December 2025 at 00:15:00 UTC, Brother Bill wrote:Can we ship our application to Production with Preconditions enabled, but with Postconditions and Invariants disabled? If so, how to? This would allow nervous managers to still have Preconditions active in Production, with slower performance. After 3 months of it "just working", they can disable the Preconditions for better performance.Yes, see https://dlang.org/dmd-linux.html#switch-check.
Nov 30
On Monday, 1 December 2025 at 03:39:22 UTC, user1234 wrote:Yes, see https://dlang.org/dmd-linux.html#switch-check.-check=[assert|bounds|in|invariant|out|switch ][=[on|off]] Overrides default, -boundscheck, -release and -unittest options to enable or disable specific checks. assert: assertion checking bounds: array bounds in: in contracts invariant: class/struct invariants out: out contracts switch: final switch failure checking on or not specified: specified check is enabled. off: specified check is disabled. If I wanted only in and switch "checked" would I add two -check arguments to CLI as ``` $ dub build -check=in=on -check=switch=on ``` or some other magic incantation?
Dec 01
On Monday, 1 December 2025 at 10:39:08 UTC, Brother Bill wrote:If I wanted only in and switch "checked" would I add two -check arguments to CLI as ``` $ dub build -check=in=on -check=switch=on ``` or some other magic incantation?One way is to export variable named DFLAGS with those options. Or, use dflags in your DUB config file - https://dub.pm/dub-reference/build_settings/#dflags
Dec 01








Dejan Lekic <dejan.lekic gmail.com>