-
-
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
Update calling-c-and-fortran docs #31700
Conversation
Maybe we can also remove some misleading docs in this PR as per discussed in JuliaInterop/Clang.jl#120 (comment) ? |
f7d3abe
to
17767b6
Compare
I suggest to rephrase or remove the above misleading statements. It just throws some "best practice" rules and doesn't explain the mechanism under the hood.
This is not right.
Again, this is not how it works. BTW, I think we'd better mention more use cases for |
|
||
```julia | ||
ccall((:foo, "libfoo"), Cvoid, (Int32, Float64), | ||
Base.unsafe_convert(Int32, Base.cconvert(Int32, x)), | ||
Base.unsafe_convert(Float64, Base.cconvert(Float64, y))) | ||
Base.convert(Int32, x), Base.convert(Float64, y)) |
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.
Why change this and remove the text below? This is not how it works and gives the wrong impression.
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.
The text below is preserved as a footnote. I wrote it this way because I felt that, for most users, cconvert
followed by unsafe_convert
was more detail than they would want to know, and that this gets the point across (i.e., that the passed values are converted to the appropriate type).
That said, I'm can change it back if you don't think the footnote is enough or appropriate.
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.
I mean, this is the docs for how to ccall
so why should I have to scroll to a footnote in order to see how ccall
works?
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.
for most users, cconvert followed by unsafe_convert was more detail than they would want to know, and that this gets the point across (i.e., that the passed values are converted to the appropriate type).
For any user, they should either not care about anything about conversion for ccall
arguments at all, or if they do, they must not related it to convert
. This change gets the wrong point across. I've recently seen people still thinking convert
is the method to use for this and it's just wrong.
Bottom line is that I don't really mind if this is said in the footnote or not, but you must not mention convert
.
@Gnimuc I'll try to address your comments today.
I don't have enough grasp of this to add anything useful. |
* Formatting, wording updates
* Revery the creation of footnote 3. Part of that note was put back into the text, and part was deleted, as it was pointed out that it was misleading. * Remove some additional misleading comments regarding the use of Ptr and Ref.
a624ecb
to
63129e5
Compare
Okay, I've "addressed" @Gnimuc's comments mostly by deleting the offending section. If anyone has some better wording that could be put in instead, please speak up! @Gnimuc @fredrikekre @yuyichao If you have time, can you take a glance through the document as it stands right now and let me know if there' s anything else that should be reworded or removed? Thanks. |
Co-Authored-By: kmsquire <kevin.squire@gmail.com>
Co-Authored-By: kmsquire <kevin.squire@gmail.com>
This is an updated version of #10799. It's almost entirely formatting and wording updates.
Comments welcome, although I probably won't be able to spend much time on this.
Maintainers should feel free to push edits.