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
Broken function support in julia-0.5 (all functions are generic) #57
Comments
Are there any workarounds in the meantime? |
If you stay on the stable release version of Julia, this shouldn't be an issue. |
I need threading, unfortunately. On Sun, Mar 6, 2016 at 10:21 AM Stefan Karpinski notifications@github.com
|
IIRC, threading was merged before jb/functions, which caused this breakage, so if you checkout the commit right before jb/functions was merged, that might do the trick for you. |
@jeff-regier, if you're willing to do some work, the best workaround would be to implement it. I can't guarantee it's even possible, but if there's only one method defined for the object, then by poking around long enough you might be able to grab the AST. Here's a head start for you: f = x->x^2
m = first(methods(f))
fieldnames(m) |
Are there any workarounds for this? Will v0.6 change anything about the internals to make this easier/doable? |
We shouldn't be grabbing ASTs here, at least in the basic case. Functions are identical to singleton types and should be treated identically. That should make the patch fairly straightforward. Closures defined in the repl are trickier as the type is obviously transient across sessions. I think it would be ok to not support that case, but we could also take inspiration from Julia serialiser if it does something smarter. |
Still getting "ERROR: UndefVarError: isgeneric not defined" in Julia 1.1.1. |
Same here. Anyone have any idea? |
This is basically the error message. LoadError: UndefVarError: isgeneric not defined |
It seems like the solution would be to delete the call to |
I'm running in to the same bug in Julia 1.5 when trying to save a |
Hello, just one example where this problem shows up: julia> using JLD
julia> struct Foo
x::Int64
f::Function
end
julia> foo = Foo(1,maximum)
Foo(1, maximum)
julia> jldopen("test.jld", "w") do file
write(file, "fooj", foo)
end
ERROR: UndefVarError: isgeneric not defined
Stacktrace:
[1] func2expr(fun::Function)
@ JLD ~/.julia/packages/JLD/6OyJe/src/JLD.jl:882
[2] JLD.AnonymousFunctionSerializer(fun::Function)
@ JLD ~/.julia/packages/JLD/6OyJe/src/JLD.jl:889
[...] Is there any workaround possible if you need to save objects whose type includes a function as field ? |
I am still experiencing this issue, is there any workaround? Example of the problem:
Output:
|
You could use Serialization: julia> using Serialization
julia> io = IOBuffer()
IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true, append=false, size=0, maxsize=Inf, ptr=1, mark=-1)
julia> serialize(io, x->x^2)
julia> bytes = take!(io)
313-element Vector{UInt8}:
0x37
0x4a
0x4c
0x11
0x04
0x00
0x00
0x00
0x34
0x33
0x13
0x04
0x00
0x00
0x00
0x00
0x00
0x00
0x00
0x01
0x06
0x23
0x31
⋮
0x00
0x09
0xff
0xff
0xff
0xff
0xff
0xff
0xff
0xff
0x4c
0x4c
0x4c
0x4c
0x03
0x00
0x03
0x00
0x4e
0x4e
0xe1
0x29
julia> io2 = IOBuffer(bytes)
IOBuffer(data=UInt8[...], readable=true, writable=false, seekable=true, append=false, size=313, maxsize=Inf, ptr=1, mark=-1)
julia> g = deserialize(io2)
#11 (generic function with 1 method)
julia> g(5)
25
|
Not sure how we should handle this.
The text was updated successfully, but these errors were encountered: