Merge enforceEx with enforce#2288
Merge enforceEx with enforce#2288dnadlinger merged 1 commit intodlang:masterfrom mihails-strasuns:enforce-unify
Conversation
Makes it possible to call `enforce!MyException` instead of `enforceEx!MyException`, eliminating redundant notation. Old enforceEx is not deprecated but removed from documentation examples.
There was a problem hiding this comment.
The patch looks very boring, I like it.
One question though, would their be any benefit of making the file and line template arguments like so:
T enforce(E : Throwable = Exception, T, string file = __FILE__, size_t line = __LINE__)(T value, lazy const(char)[] msg = null)and passing it like this all the way to bailOut. I would image the compiler could take some advantage of that.
There was a problem hiding this comment.
No. It would only lead to a gazillion of duplicate enforce functions being created, and with longer mangled names.
There was a problem hiding this comment.
thank you for the quick reply, I see my mistake
There was a problem hiding this comment.
I believe we had it like this at one point, though, so it's not a completely outlandish suggestion. ;)
|
LGTM. |
|
Auto-merge toggled on |
|
Okay, let's go ahead with this. There might still be a small chance of breakage if somebody used enforce in an obscure way, but we'll find out during the next beta. |
Merge enforceEx with enforce
Anyone complained? |
I remember lot of negative opinions about breaking changes in Phobos for the sake of just naming - wanted to increase the chances of this PR to be merged :) I think we can try deprecating it in next release if no one is against it. |
|
(I don't know of any complaints) |
|
Deprecation isn't breaking and we should still deprecate enforcers, starting by removing the documentation. |
What about the overload, this change as is might break code without warning. |
|
This pull request introduced an accepts-invalid regression: |
Makes it possible to call
enforce!MyExceptioninstead ofenforceEx!MyException, eliminatingredundant notation. Old enforceEx is not deprecated but removed from documentation examples.
This fixes one of very common Phobos "WAT" moments for me - having separate name for semantically identical
function with a different argument set.