Skip to content
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

Error when calling cfunction on a constructor #26070

Closed
danielmatz opened this issue Feb 15, 2018 · 2 comments · Fixed by #26486
Closed

Error when calling cfunction on a constructor #26070

danielmatz opened this issue Feb 15, 2018 · 2 comments · Fixed by #26486

Comments

@danielmatz
Copy link
Contributor

If one calls cfunction on a constructor, Julia throws an error about closures.

julia> struct Thing
       x::Int
       end

julia> cfunction(Thing, Ref{Thing}, (Int,))
ERROR: closures are not yet c-callable
Stacktrace:
 [1] cfunction(::Type{T} where T, ::Type{T} where T, ::Tuple{DataType}) at ./c.jl:24

There is some discussion on Discourse, where it was suggested that this is a bug.

I've tested this on two different machines, and both give the same behavior. The versioninfo output for each is below.

julia> versioninfo()
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin14.5.0)
  CPU: Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, has well)
julia> versioninfo()
Julia Version 0.6.2
Commit d386e40 (2017-12-13 18:08 UTC)
Platform Info:
  OS: Linux (x86_64-redhat-linux)
  CPU: Intel(R) Xeon(R) CPU E5-2690 v4 @ 2.60GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, broadwell)
@vtjnash
Copy link
Member

vtjnash commented Feb 15, 2018

oy vey, this is a surprisingly hard one, since – for our current capabilities – we would need to detect whether the type is a singleton instance (where type-equal implies egal).

I've also recently started putting down thoughts about supporting closures, which would just solve the whole issue: https://github.com/vtjnash/julep/wiki/0004:-Static-compilation-for-cfunction

@vtjnash
Copy link
Member

vtjnash commented Mar 16, 2018

dup #1096

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants