digitalmars.D.learn - Query for -dip1000
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (15/15) Feb 10 2019 Is there a way to query if the -dip1000 flag has been passed to
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (3/4) Feb 10 2019 Oops, I had already posted that and got an answer at
- Jonathan M Davis (7/23) Feb 11 2019 A quick grep of Phobos shows a version(DIP1000) block in std/typecons.d,
- Seb (5/13) Feb 11 2019 That one has been added manually:
- Jonathan M Davis (15/31) Feb 11 2019 Honestly, having an explicit version is far better than trying to detect...
- Meta (2/17) Feb 11 2019 https://issues.dlang.org/show_bug.cgi?id=19669
Is there a way to query if the -dip1000 flag has been passed to the compiler? I need it for enabling certain DIP-1000 escape analysis tests only when -dip1000 has been passed. For instance static assert(!__traits(compiles, { char[] f() { char[2] x; return x[].splitterASCII!(_ => _ == ' ').front; } })); at https://github.com/nordlow/phobos-next/blob/bd2fe42978aab2313977042c858d77c5766538e8/src/splitter_ex.d#L110 Or do I have to write a trait myself?
Feb 10 2019
On Sunday, 10 February 2019 at 20:04:29 UTC, Per Nordlöw wrote:Or do I have to write a trait myself?Oops, I had already posted that and got an answer at https://forum.dlang.org/post/qglynupcootocnnnpmhj forum.dlang.org
Feb 10 2019
On Sunday, February 10, 2019 1:04:29 PM MST Per Nordlöw via Digitalmars-d- learn wrote:Is there a way to query if the -dip1000 flag has been passed to the compiler? I need it for enabling certain DIP-1000 escape analysis tests only when -dip1000 has been passed. For instance static assert(!__traits(compiles, { char[] f() { char[2] x; return x[].splitterASCII!(_ => _ == ' ').front; } })); at https://github.com/nordlow/phobos-next/blob/bd2fe42978aab2313977042c858d77 c5766538e8/src/splitter_ex.d#L110 Or do I have to write a trait myself?A quick grep of Phobos shows a version(DIP1000) block in std/typecons.d, which appears to be used to make it so that a particular unittest block is only compiled in when -dip1000 is used, so it looks like there's a version identifier for it. - Jonathan M Davis
Feb 11 2019
On Monday, 11 February 2019 at 09:29:13 UTC, Jonathan M Davis wrote:On Sunday, February 10, 2019 1:04:29 PM MST Per Nordlöw via Digitalmars-d- learn wrote:That one has been added manually: https://github.com/dlang/phobos/blob/master/dip1000.mak The detection would have been better...[...]A quick grep of Phobos shows a version(DIP1000) block in std/typecons.d, which appears to be used to make it so that a particular unittest block is only compiled in when -dip1000 is used, so it looks like there's a version identifier for it. - Jonathan M Davis
Feb 11 2019
On Monday, February 11, 2019 3:23:25 AM MST Seb via Digitalmars-d-learn wrote:On Monday, 11 February 2019 at 09:29:13 UTC, Jonathan M Davis wrote:Honestly, having an explicit version is far better than trying to detect it in an ad-hoc manner. It's actually guaranteed to be right in that case, whereas ad-hoc tests are more likely to have problems - especially if they're around for a while, and things change that weren't anticipated when the code was written. So, I'd actually argue that manually setting it as part of the build was a better idea than trying to detect it, but if it's manually set as part of the build instead of being built into the compiler, then it doesn't help anyone else. Though honestly, it seems to me that having version identifiers for transitional compiler flags like that is probably a good idea, since it makes transitioning code easier. The best that we can do otherwise is generally using __VERSION__, and that only works once the change is the default. - Jonathan M DavisOn Sunday, February 10, 2019 1:04:29 PM MST Per Nordlöw via Digitalmars-d- learn wrote:That one has been added manually: https://github.com/dlang/phobos/blob/master/dip1000.mak The detection would have been better...[...]A quick grep of Phobos shows a version(DIP1000) block in std/typecons.d, which appears to be used to make it so that a particular unittest block is only compiled in when -dip1000 is used, so it looks like there's a version identifier for it. - Jonathan M Davis
Feb 11 2019
On Sunday, 10 February 2019 at 20:04:29 UTC, Per Nordlöw wrote:Is there a way to query if the -dip1000 flag has been passed to the compiler? I need it for enabling certain DIP-1000 escape analysis tests only when -dip1000 has been passed. For instance static assert(!__traits(compiles, { char[] f() { char[2] x; return x[].splitterASCII!(_ => _ == ' ').front; } })); at https://github.com/nordlow/phobos-next/blob/bd2fe42978aab2313977042c858d77c5766538e8/src/splitter_ex.d#L110 Or do I have to write a trait myself?https://issues.dlang.org/show_bug.cgi?id=19669
Feb 11 2019