-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Export jl_get_function #22190
Export jl_get_function #22190
Conversation
We have this as an example in the docs, so it should actually be usable. I don't know why it was initially declared STATIC_INLINE, but it does enough work that inlining seems pointless. ref: https://stackoverflow.com/questions/44314254/embedding-julia-script-into-c-jl-get-function-doesnt-exist
58698a5
to
5f0e564
Compare
Being in the header should be enough. |
Mind to expand on that?
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I'm saying is that we shouldn't do this.
- It being not exported doesn't matter. A static inline function in the header is a public API.
- We don't guarantee and will never be able to guarantee that all public C API are exported functions
- This function is a simple helper for C code which is why it's a static inline function. It isn't as useful for scripting. The right fix here is to document what this function do and what scripting language binding can do.
Ok. Ideally there would be a documented difference between the "julia.h public C API" and the "(non-include) embeddable C API with export guarantees" (look at Python or Lua for example). Probably 50% of the embedding questions we get are about using Julia from non-C languages, and I don't think it is unreasonable for people to try to translate the manual examples without deeply understanding the whole |
FWIW, small functions like this would be the last thing they need to worry about in terms of function/macro. The GC push and pop macros cannot be functions and the code in that stackoverflow questions is missing at least 3 roots. |
If Julia only supports embedding in C and C++, then that seems like a fairly important thing to document... |
No that's not at all the case, since pyjulia exists. The embedding doc, and more importantly the examples in the embedding doc, is obviously in C/C++. What other language to do strongly depends on the language ffi and the limitation of those ffi implementation should be familiar to anyone who want to write language bindings. As an example, I believe python's cffi would have no issue at all calling the inlined |
Ok, fair enough. For
pyjulia uses the "global root array" implemented in PyCall for every object conversion. A similar, generic
In a CPython extension? Sure ... |
I agree. It was removed because it never does that.... I think it'll be useful to have a simulated ref counting API. Though I'll probably not work on it unless there's more general interest.... And I'm using cffi just as an example of a (C) "API" level ffi. The |
Hello, sorry to fall back very late on this, but I started working on binding the |
It is simply |
@vtjnash the problem is I have to handle a |
All objects should typically be handled as |
@vtjnash Well, this works in C/C++, but how would you adapt this to C# ? With
I get Memory Access violation errors, while I only use pointers to handle data... |
We use this as an example in the docs, so it should actually be usable.
I don't know why it was initially declared STATIC_INLINE, but it does
enough work that inlining seems pointless.
ref:
https://stackoverflow.com/questions/44314254/embedding-julia-script-into-c-jl-get-function-doesnt-exist