This doesn’t seem to match with @c42f’s statement in the linked thread:
Not sure who’s right here?
Yes, this is what I’m saying: This shouldn’t fail at the syntax level. The length check should instead be done at compile- or runtime.
What I’m arguing for is making ccall
less special. Normal function calls in Julia don’t behave like this syntactically, and given that it looks the same, it would be better for ccall
to behave as closely to a normal function call as possible.
The ...
in the code refers to specifying varargs in the type signature, as in
julia> ccall(:printf, Cint, (Cstring, Cint...), "%d %d %d\n", 1, 2, 3);
1 2 3
which is yet another special-case syntax that only exists within the context of ccall
.
I don’t know if “link time” refers to something else in the context of Julia, but in C, you can link to functions perfectly fine without even specifying any function signature. And of course, with varargs you’ll also never know how many arguments are going to be passed, and this number can change, too. So I’m not sure what the problem would be here.
And the result is a clearer, more consistent, and more flexible syntax, even within the constraints of the current implementation of ccall
. Wouldn’t it be better if ccall
worked like this?