Closed aviks closed 8 years ago
julia> macroexpand(:(@memoize foo(x) = 3))
quote # /Users/aviks/.julia/v0.4/Memoize/src/Memoize.jl, line 92:
foo_unmemoized(x) = begin # none, line 1:
3
end # /Users/aviks/.julia/v0.4/Memoize/src/Memoize.jl, line 93:
#545#isdef = false # /Users/aviks/.julia/v0.4/Memoize/src/Memoize.jl, line 94:
try # /Users/aviks/.julia/v0.4/Memoize/src/Memoize.jl, line 95:
foo # /Users/aviks/.julia/v0.4/Memoize/src/Memoize.jl, line 96:
#545#isdef = true
catch
end # /Users/aviks/.julia/v0.4/Memoize/src/Memoize.jl, line 98:
if #545#isdef # /Users/aviks/.julia/v0.4/Memoize/src/Memoize.jl, line 99:
for #546#i = 1 # /Users/aviks/.julia/v0.4/Memoize/src/Memoize.jl, line 100:
begin # /Users/aviks/.julia/v0.4/Memoize/src/Memoize.jl, line 101:
local fcache # /Users/aviks/.julia/v0.4/Memoize/src/Memoize.jl, line 102:
const fcache = ObjectIdDict() # /Users/aviks/.julia/v0.4/Memoize/src/Memoize.jl, line 103:
foo(x) = begin # /Users/aviks/.julia/v0.4/Memoize/src/Memoize.jl, line 103:
if haskey(fcache,(x,))
fcache[(x,)]
else
fcache[(x,)] = foo_unmemoized(x)
end
end
end
end
else # /Users/aviks/.julia/v0.4/Memoize/src/Memoize.jl, line 109:
begin # /Users/aviks/.julia/v0.4/Memoize/src/Memoize.jl, line 110:
const foo = let # /Users/aviks/.julia/v0.4/Memoize/src/Memoize.jl, line 111:
local fcache, foo # /Users/aviks/.julia/v0.4/Memoize/src/Memoize.jl, line 112:
const fcache = ObjectIdDict() # /Users/aviks/.julia/v0.4/Memoize/src/Memoize.jl, line 113:
foo(x) = begin # /Users/aviks/.julia/v0.4/Memoize/src/Memoize.jl, line 113:
if haskey(fcache,(x,))
fcache[(x,)]
else
fcache[(x,)] = foo_unmemoized(x)
end
end
end
end
end
end
This looks to have been fixed in base julia, and now works at least as of Version 0.5.0-dev+3660 (2016-04-20 14:02 UTC)
.
This bug occurs in latest Julia Version 0.5.0-dev+4987 Commit 3ac1e62* (2016-06-28 18:44 UTC)
Yes, I was just searching for this issue to say the same thing. Ah well.
The obvious way to fix this does not work (JuliaLang/julia#18672)
In Julia
0.5
This works OK in
v0.4
cc: @jeffbezanson : I presume this is due to the function rework. Is there an easy workaround that comes to mind?