-
-
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
@inbounds
loses expression value
#9774
Comments
I think you can fix this by writing I think that you could change the implementation of
This has the disadvantage that it would "eat up" return statements. That is, code such as
would be translated into a sequence such as the one above, where the The underlying problem here is that
is actually sensible code, and the |
I forced everything into statement position to defer possible evaluation-reordering problems. Yes, this is a messy compile-time feature. I think an efficient run-time version of this is extremely hard! Obviously anything like |
Could |
Ref #8227 for further discussion of possible reimplementations of |
Closing, as everything here is covered by #8227. Currently the original function has to be written function bar(x,j)
@inbounds return x[j]
end but as all statements in Julia return a value (or |
Actually, there is one statement that does not return anything: |
There might be a misunderstanding here. julia> f() = return
f (generic function with 1 method)
julia> typeof(f())
Void
|
I was comparing the However, it is exactly this property of the
is ill-formed if However, |
Ah, thanks for the explanation. |
It appears that wrapping an expression in
@inbounds
causes its value to be lost.This seems surprising. If there's no easy way to fix the surprise, let's at least document it.
The text was updated successfully, but these errors were encountered: