-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Deprecate assert function in favor of at-assert macro #12565
Conversation
👎 this is used in a lot of code. I don't get what we gain here for all the code churn. |
I am not sure I understand what you mean. |
Every time someone deprecates something, that means broken code in 2 release cycles or piles of deprecation warnings to go through and fix. |
@jakebolewski Am I correct that your objection is to the deprecation of |
Of course, sorry for the implied tone (my anger has been honed by fixing too many deprecation warnings). |
At a quick search of Github for assert in Julia code, |
This is what I'm basing that on: |
Just because one is used more, doesn't mean that they can't coexist. |
Two ways to do same thing, where one is inflexible and has quite a different meaning to the |
+:100:. Having two such similar things in Base is annoying and pointless. The deprecation objection is, imo, kind of lazy and defeatist. Sure, dealing with deprecations is tedious, but the alternative is to settle for leaving things permanently in a broken, crappy state just because it's annoying to fix them. The only legitimate argument for not deprecating something we know is lousy is that we're not sure what would be better. In this case that argument doesn't apply. |
@@ -374,6 +374,10 @@ end | |||
|
|||
@deprecate ntuple(n::Integer, f::Function) ntuple(f, n) | |||
|
|||
# 8856 | |||
export assert |
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.
The export is probably not necessary here since the @deprecate
macro automatically exports.
It is not annoying and pointless. One is much more efficient than the other because it doesn't have to allocate. |
A better solution would be to figure out how to avoid allocation in the macro version which is used far more often. |
sure, but you are advocating removing one version when there is no alternative in place. |
The performance argument is a very valid one, so unfortunately I guess we'll have to wait on this. |
I'm not sure if I mentioned it in my initial issue, but I don't think |
I really see no point to |
Is |
It is always being compiled, which was my suggestion here #8856 (comment) |
@IainNZ I'm not dead set against the change you point out, only deprecating something without providing a compelling enough alternative. |
We should have a way to disable assert statements but I don't think the debug build is a good way. People don't usually keep around two versions of the executable. A command line argument is easier. It leaves the question open of already compiled code obviously. |
Have the generated code always test a global flag, and generate nothing at all if it wasn't already compiled. State of this flag may need to go in cached precompiled file. |
Related: #10614. @ScottPJones what @carnaval is saying is that you can never enforce that all the assertions are turned on or off, it depends on the phasing of when code is precompiled and what global flags were or were not turned on at the time. |
@jakebolewski Yes, that is why I said, if it does compile it in, it should still have a run-time check of the global flag, before actually executing the assertion test (which could be expensive). |
Who is people? Developer? As a normal user, I am perfectly happy to rely on whatever decision regarding assertions the developer has taken. I am already relying on the developer for decision regarding the algorithm. I have a limited understanding of assertions, so I am probably wrong, but shouldn't there be assertions that have to be run no matter what (and it is up to the developer to make sure they do not impact performance) and debug assertions that are turned off in high-performance code? Please do ignore this comment if it doesn't make any sense... |
The discussion in #10614 (and I think at least one other earlier issue that I can't seem to find) went pretty much that same direction. There are some safety critical assertions you never want to disable and some check-only assertions that you'd want to turn off in "release" code somehow. But anyway I don't think you need to solve that issue here. I'm in favor of deprecating the
|
Tests that you always want performed should be done as |
So for instance in https://github.com/JuliaLang/julia/blob/master/base/inference.jl#L766, the line should be
|
@michele-zaffalon I'm just saying that since we can compile julia code on the fly independently of the julia executable it does not make sense to tie a codegen option (assertions-enabled) with the julia build version (debug). As for this example, I think in that case the argument types array is always generated inside inference so this assertion should not trigger even on broken AST. However, if your point is that it's so cheap compared to what's being done there that we might as well just want to leave it in anyway, you're right. |
Or maybe
since this is closer to an assert, and states the condition that will hold in the code below. |
@eschnett Yes (although for that particular case, maybe you should use a DimensionMismatch() error?) |
Superseded by #26194. |
fixes first half of #8856