# Is it possible to splat into ccall?

**URL:** <https://discourse.julialang.org/t/is-it-possible-to-splat-into-ccall/95761>\
**Category:** General Usage\
**Tags:** ccall\
**Created:** [March 8, 2023, 7:49pm UTC](https://discourse.julialang.org/t/is-it-possible-to-splat-into-ccall/95761 "2023-03-08T19:49:46Z")\
**Posts on this page:** 1\
**Showing post:** 30

<div class="post-metadata">

**Author:** ![uniment](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/uniment/32/24532_2.png) [@uniment](https://discourse.julialang.org/u/uniment)\
**Post date:** [March 28, 2023, 4:35am UTC](https://discourse.julialang.org/t/is-it-possible-to-splat-into-ccall/95761/30 "2023-03-28T04:35:34Z")

</div>

A couple notes and ideas, fwiw

1. For separating args from varargs, I see appeal in using `…`, but it seems like `:` would be more ergonomic. Subjective of course. You could use any other operator too, like `|`, `>`, etc, or maybe wrap the varargs in their own tuple.
2. For the method using `Pair`s like `2=>Cint`, it feels a bit backwards; `Cint=>2` feels more natural to me. Another idea would be to use `Cint: 2`, though that’s likely to get pushback as it would entail [type piracy](https://docs.julialang.org/en/v1/manual/style-guide/#Avoid-type-piracy), but that could be solved by getting it into `Base`.
3. As discussed in [this thread](https://discourse.julialang.org/t/why-are-generated-functions-maybe-impossible-to-statically-compile/96366), there might be difficulties in getting some programs that use such a generated function to compile statically. That said, `ccall` already seems to [cause trouble](https://discourse.julialang.org/t/about-static-compilation-and-static-analysis/87492/6) for static compilation. I haven’t dug in to understand why.

If we’re willing to diverge from existing semantics a bit more, maybe something like this becomes compelling:

```julia
Ccall(Cdouble: :pow, Cdouble: 2, Cdouble: 10)
Ccall(Cint: :printf, Cstring: "%d %f %s\n", (Cint: 1, Cdouble: 2.0, Cstring: "Hello"))

```

or maybe:

```julia
Ccaller(Cdouble, :pow, Cdouble, Cdouble)(2, 10)
Ccaller(Cint, :printf, Cstring, (Cint, Cdouble, Cstring))("%d %f %s\n", (1, 2.0, "Hello"))

```

Chef’s choice.

---

_[View the full topic](https://discourse.julialang.org/t/is-it-possible-to-splat-into-ccall/95761)._
