-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Add semantics for varargs of different types to ccall. #32758
Comments
And as for syntax, I have no strong opinions, but I can suggest this as a starting point for the conversation, based on what we currently have: ccall(:printf, Cint, (Cstring, (Cstring, Cint)...), "%s = %d\n", "value of x", x) It ain't pretty, but it's backward compatible. |
sort of a duplicate of #6661, but I'm not a particular fan of that syntax proposal anymore |
The semicolon-based alternative syntax would be this: ccall(:printf, Cint, (Cstring; Cstring, Cint), "%s = %d\n", "value of x", x) Note that this could potentially be combined with an ellipsis to indicate that all varargs arguments are of the same type, e.g.: ccall(:printf, Cint, (Cstring; Cint...), "%d = %d + %d\n", x + y, x, y)
ccall(:printf, Cint, (Cstring, Cint...), "%d = %d + %d\n", x + y, x, y) # might mean the same thing It's unclear how that would be written in the |
I do kind of like that. Seems like Note that you need a ccall(:printf, Cint, (Cstring,; Cstring, Cint), "%s = %d\n", "value of x", x)
`` |
Looks like it sees a tuple if there is a comma somewhere on either side of the semicolon. Otherwise, it sees a "block". julia> :( (this; that) ).head
:block
julia> :( (this; that, theother) ).head
:tuple |
Seems like we could also teach ccall to understand the expressions sequence form, although that’s a bit of a cheat and would probably allow other unintentional syntaxes too. |
I'm working on a PR, #32748, for a macro wraps
ccall
in more Julia-like syntax. An issue that's being discussed a lot is the accommodation of varargs of different types. I had the impression from @vtjnash that this was supported byforeigncall
, but in retrospect, it's possible I misunderstood what he was saying.I'm not in a position to implement this myself without first learning Scheme and LLVM. I should really do those things, but it may not be the most efficient way to get this change in.
The text was updated successfully, but these errors were encountered: