You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: http://docs.julialang.org
_ _ _| |_ __ _ | Type "?help" for help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.5.0-rc2+0 (2016-08-12 11:25 UTC)
_/ |\__'_|_|_|\__'_| | Official http://julialang.org/ release
|__/ | x86_64-w64-mingw32
julia> function f(x)
if x
bar()=5
else
bar()=1
end
return bar
end
WARNING: Method definition bar() in module Main at REPL[1]:3 overwritten at REPL[1]:5.
f (generic function with 1 method)
julia> f(true)
(::bar) (generic function with 1 method)
julia> f(false)
ERROR: UndefVarError: bar not defined
in f(::Bool) at .\REPL[1]:7
julia>
There are two things that I find strange: why is there a warning when I compile f? And why doesn't the second invocation work?
I am aware that one can use anonymous functions instead.
It is not clear to me whether this is a bug, or by design. If by design, it would be good to mention this in the NEWS section. Also, if by design, is there still a point to allow these nested function definitions at all?
The text was updated successfully, but these errors were encountered:
This used to work on julia 0.4:
There are two things that I find strange: why is there a warning when I compile
f
? And why doesn't the second invocation work?I am aware that one can use anonymous functions instead.
It is not clear to me whether this is a bug, or by design. If by design, it would be good to mention this in the NEWS section. Also, if by design, is there still a point to allow these nested function definitions at all?
The text was updated successfully, but these errors were encountered: