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

Base.CFunction is user-visible but undocumented #27490

Closed
stevengj opened this issue Jun 8, 2018 · 2 comments · Fixed by #27506
Closed

Base.CFunction is user-visible but undocumented #27490

stevengj opened this issue Jun 8, 2018 · 2 comments · Fixed by #27506
Assignees
Labels
docs This change adds or pertains to documentation

Comments

@stevengj
Copy link
Member

stevengj commented Jun 8, 2018

#26486 introduced a struct CFunction in Base that is returned by @cfunction for interpolated function arguments:

julia> @cfunction $sin Float64 (Float64,)
Base.CFunction(Ptr{Nothing} @0x0000000116262a90, sin, Ptr{Nothing} @0x0000000000000000, Ptr{Nothing} @0x0000000000000000)

Although this type is user-visible, it is currently undocumented (both in the @cfunction docs and because it lacks a docstring).

CFunction has an unsafe_convert method to Ptr{Cvoid}, so it can be passed as a callback argument. (But CFunction doesn't work with ccall!) But users still need to know about the type — e.g. in PyCall I have to store it in a struct.

(Should this type be exported?)

@stevengj stevengj added the docs This change adds or pertains to documentation label Jun 8, 2018
@StefanKarpinski StefanKarpinski added this to the 1.0.x milestone Jun 8, 2018
vtjnash added a commit that referenced this issue Jun 8, 2018
This struct had a brief mention in the manual,
but was missing NEWs and info about usage

fix #27490
@vtjnash
Copy link
Member

vtjnash commented Jun 8, 2018

But users still need to know about the type — e.g. in PyCall I have to store it in a struct.
(Should this type be exported?)

I think I should make it a subtype of Ref{Cvoid} – that's typically the expected annotation for most of these ccall-related APIs. Note though that if python provides a void *env-type argument, it's much more efficient to use that argument for its intended purpose (much as you would have done in the past), rather than to ignore the argument and use the dynamic closures (as provided by $ and struct CFunction).

@StefanKarpinski
Copy link
Member

Can't we just document the type as it is?

vtjnash added a commit that referenced this issue Jun 11, 2018
This struct had a brief mention in the manual,
but was missing NEWs and info about usage

fix #27490
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This change adds or pertains to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants