-
-
Notifications
You must be signed in to change notification settings - Fork 668
Implement DIP1006 - more selective control over run-time checks #7980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Thanks for your pull request, @MartinNowak! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + dmd#7980" |
|
Regarding |
All on one page: https://digitalmars.com/d/archives/digitalmars/D/DIP_1006_-_Preliminary_Review_Round_1_299766.html |
|
I appreciate the quick implementation of this, but it does not match the DIP, and one or the other needs to be changed. |
Geod24
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First, thanks for taking care of this @MartinNowak !
I made a few comments.
I don't care much about the name itself, and as they stand they look good enough to me. However, as I mentioned a few times, I strongly feel that disabling assert should disable in/out/invariant, because if assert are disabled, those code blocks are useless, and IMO it would be confusing to have them on.
| auto tail = arg["-release=".length .. $]; | ||
| while (true) | ||
| { | ||
| auto delim = strchr(tail.ptr, ','); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we were not supporting CLI with comma ? After #7863
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with the approved CLI interface for DIP1006, whether commas were approved. If commas were approved then we should establish a convention on when and when not to support commas, and then use a common implementation for comma support. If it were approved, I would think it would also apply to options like -i and -version...but this is all moot if commas are not approved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I picked commas because it allows to override previous occurences of that argument, sometimes useful when using other peoples projects and Makefiles. Less of an argument for switches like include paths that are expected to be additive.
|
|
||
| // switch without default is now a compile-time error anyhow | ||
| if (params.useSwitchError == CHECKENABLE._default) | ||
| params.useSwitchError = CHECKENABLE.off; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I understand correctly that those 2 get affected even if I just provide -release=invariant ? That sounds odd.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switch fallthrough errors are dead, they're a compile-time error nowadays.
changelog/dip1006.dd
Outdated
| @@ -0,0 +1,4 @@ | |||
| allow to disable only specific run-time checks | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be capitalized ? ("Allow")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently yes
Just to note: I would have written up a DIP for the The major advantage of this approach over DIP1006 is that the options presented are not hierarchical, so it gives more control to the developer over how it can be used.
This isn't true. We don't know, and can't know, what people are doing inside their contracts (which might still be useful even with It's also simpler to understand if |
This is a shame, because one very nice aspect to Acknowledging that it would be quite some effort, what do you see as the main difficulties/obstacles in implementing the fine-grained switch? |
Someone can use @MartinNowak : Have you actually seen someone throwing exceptions from invariants / contracts ? |
Who said anything about throwing exceptions? Using |
We have a few D users that are extensively using contracts and might want to do so even in a production environment.
In order to enable asserts in some contexts but keep it disabled in others, we'd have to correctly infer the current context, which is not too trivial given the existing complexity in contracts and considering language features such a nested functions and mixin templates.
Yip, this PR was intended to push the discussion/design towards a decision dlang/DIPs#64 (comment). Let me mark it as WIP though. |
That might be another option, then we could just have |
That's a fair point, and one that occurred to me too: I didn't follow the difference between @Geod24's proposal for It would certainly be feasible (and reasonable) to start with just |
I'd have assumed that would be a simplifying factor, because Are these edge cases your primary concern or is there inherently a difficulty with checking if the context of an Anyway,
... this is what I assumed you had in mind when talking about |
Just adding |
In contracts, we only use It could be helpful, however, to keep only So, adding |
|
|
|
Great -- glad we are able to come to a consensus here, as this is a nice feature to be able to move forward with. |
FWIW Walter previously objected to adding a comma parser as the 80 lines needed for its generic support for all arguments "wasn't justified" :/ |
- allow to disable only some run-time checks e.g. with -release=in,out,invariant - cli was proposed in DIP1006 review discussion https://forum.dlang.org/post/rsafosvkhxddkxptaziy@forum.dlang.org but hasn't yet been added to https://github.com/dlang/DIPs/blob/master/DIPs/DIP1006.md
wilzbach
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's really a shame that such good work dies in the PR queue. Also the DIP has been submitted more than a year ago and is still in "the final review" stage.
In my viewpoint this helps a lot of users and apparently @andralex and @WalterBright have not a huge interest in this. So I'm ready to pull this.
-> I added the "72h no objections -> merge".
If you have any final concerns, you should speak now!
|
This is on me now, I've been contacted a month or so to take over the DIP from @Geod24 's hands and we are talking in private with W&A for the final review and they are requesting changes to accept it (basically to use Sorry for the delay. |
|
@MartinNowak why close this? |
|
Probably because of #8972. |
https://forum.dlang.org/post/rsafosvkhxddkxptaziy@forum.dlang.org
but hasn't yet been added to https://github.com/dlang/DIPs/blob/master/DIPs/DIP1006.md