Is it possible to splat into ccall?

Well, the canonical example would be varargs functions in C (e. g. as linked in my original post):

I used pow as an example because I wanted to focus on the syntax without adding the complications that come with varargs. Using @uniment’s method, the linked printf example becomes

julia> ccaller{:printf, :Cint, (:Cstring, ntuple(_ -> :Cint, 5)...)}("%d %d %d %d %d\n", (1:5)...);
1 2 3 4 5

without @eval – much better!

But to be honest, that isn’t even how I came across this question. I just have some C functions (in an external library) with annoyingly long argument lists (9 arguments) that I wanted to call and validate/transform the arguments for. Instead of copy-pasting the same code 9 times to handle each argument, I tried to pack them in a tuple and process them in a loop instead. So now I already have the arguments as a tuple, so the easiest (and least error-prone!) way of passing them to ccall would be to use splatting. Of course I could also just index all 9 arguments individually, but that just seems stupid when splatting exists! We’re not writing C here after all.

So just for illustration, what I wanted to write was

function external_func_wrapper(args::NTuple{9, Integer})
	for x in args
		validate(x) || error(x)
	end
	return ccall(
		:external_func, Cdouble,
		(Cint, Cint, Cint, Cint, Cint, Cint, Cint, Cint, Cint),
		(transform(x) for x in args)...
	)
end

But since that’s not allowed, I’d have to change it to

function external_func_wrapper(args::NTuple{9, Integer})
	for x in args
		validate(x) || error(x)
	end
	arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 =
		(transform(x) for x in args)
	return ccall(
		:external_func, Cdouble,
		(Cint, Cint, Cint, Cint, Cint, Cint, Cint, Cint, Cint),
		arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9
	)
end

which makes me list the entire indexed argument list twice, instead of not at all if splatting were allowed.

I don’t really agree with this. I’d even almost say it’s the opposite: The fact that “hacks” like @uniment’s method exist demonstrates that there isn’t any fundamental reason why this shouldn’t work. Clearly, Julia has all the information necessary to determine whether the call is valid and carry it out. It’s just that ccall arbitrarily rejects this specific syntax. As you say yourself in that same thread I linked above: