-
-
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
Passing redefined function as argument #18353
Comments
Dup of #265 |
And your case is discussed in #265 already #265 (comment) |
Sorry, missed that. However, will the fix of #265 get backported to 0.5 as well? It only has the 0.6 milestone at the moment. |
No this is unlikely going to be fixed in 0.5. |
In that case I would maintain that it's somewhat of an annoying regression compared to 0.4 😞. At least for me the REPL workflow where I keep redefining functions in the global scope is pretty common. |
Should it at least be mentioned in |
sure. fastest way would be to propose a wording which we could iterate on in a PR |
Is there any work-around? |
The workaround would be to use anonymous functions: julia> q(n) = 0
q (generic function with 1 method)
julia> map(x->q(x), 1:1)
1-element Array{Int64,1}:
0
julia> q(n) = 1
WARNING: Method definition q(Any) in module Main at REPL[1]:1 overwritten at REPL[5]:1.
q (generic function with 1 method)
julia> map(x->q(x), 1:1)
1-element Array{Int64,1}:
1 |
The following code, where we pass a function as an argument, redefine it and pass it again,
doesn't work as expected on 0.5 and 0.6, outputting:
I am guessing it's due to #265 and the fact that every function is a separate type now.
However, unlike most of #265, it's a regression compared to 0.4, since there we get what we would expect:
Sorry if this has already been discussed, but I was not able to find any mention of this. I do feel that perhaps this is something that should be addressed in 0.5, since the regression makes REPL work a bit more tedious.
The text was updated successfully, but these errors were encountered: