<p dir="auto">I'm working on a  PR, <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="475113064" data-permission-text="Title is private" data-url="https://github.com/JuliaLang/julia/issues/32748" data-hovercard-type="pull_request" data-hovercard-url="/JuliaLang/julia/pull/32748/hovercard" href="https://github.com/JuliaLang/julia/pull/32748">#32748</a>, for a macro wraps <code class="notranslate">ccall</code> 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 <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/vtjnash/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/vtjnash">@vtjnash</a> that this was supported by <code class="notranslate">foreigncall</code>, but in retrospect, it's possible I misunderstood what he was saying.</p>
<p dir="auto">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.</p>
<p dir="auto">proposal: introduce <code class="notranslate">va_list</code> type for <code class="notranslate">ccall</code> / <code class="notranslate">cfunction</code></p>
<p dir="auto">usage:</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="ccall(:abc, Int, (A, B, va_list{(C,D,E)}), a,b,c,d,e)
# int abc(A, B, ...) {}
# {
# abc(a,b,c,d,e);
# }

va = va_list(c,d,e)
ccall(:abc, Int, (A, B, va_list), a, b, va)
ccall(:abc, Int, (A, B, va_list{()}), a, b, va)
# int abc(A, B, va_list) {}
# {
# va_list ap;
# va_start(ap, X);
# abc(A,B, ap);
# }"><pre class="notranslate"><span class="pl-c1">ccall</span>(<span class="pl-c1">:abc</span>, Int, (A, B, va_list{(C,D,E)}), a,b,c,d,e)
<span class="pl-c"><span class="pl-c">#</span> int abc(A, B, ...) {}</span>
<span class="pl-c"><span class="pl-c">#</span> {</span>
<span class="pl-c"><span class="pl-c">#</span> abc(a,b,c,d,e);</span>
<span class="pl-c"><span class="pl-c">#</span> }</span>

va <span class="pl-k">=</span> <span class="pl-c1">va_list</span>(c,d,e)
<span class="pl-c1">ccall</span>(<span class="pl-c1">:abc</span>, Int, (A, B, va_list), a, b, va)
<span class="pl-c1">ccall</span>(<span class="pl-c1">:abc</span>, Int, (A, B, va_list{()}), a, b, va)
<span class="pl-c"><span class="pl-c">#</span> int abc(A, B, va_list) {}</span>
<span class="pl-c"><span class="pl-c">#</span> {</span>
<span class="pl-c"><span class="pl-c">#</span> va_list ap;</span>
<span class="pl-c"><span class="pl-c">#</span> va_start(ap, X);</span>
<span class="pl-c"><span class="pl-c">#</span> abc(A,B, ap);</span>
<span class="pl-c"><span class="pl-c">#</span> }</span></pre></div>
<p dir="auto">definitions:</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="immutable va_list{T&lt;:Tuple}
  # opaque
  va_list(args...) = (T == () ? new(magic...) : error(&quot;cannot construct a typed va_list&quot;))
end
va_list(values...) = va_list{()}(values...)"><pre class="notranslate">immutable va_list{T<span class="pl-k">&lt;:</span><span class="pl-c1">Tuple</span>}
  <span class="pl-c"><span class="pl-c">#</span> opaque</span>
  <span class="pl-en">va_list</span>(args<span class="pl-k">...</span>) <span class="pl-k">=</span> (T <span class="pl-k">==</span> () <span class="pl-k">?</span> <span class="pl-c1">new</span>(magic<span class="pl-k">...</span>) <span class="pl-k">:</span> <span class="pl-c1">error</span>(<span class="pl-s"><span class="pl-pds">"</span>cannot construct a typed va_list<span class="pl-pds">"</span></span>))
<span class="pl-k">end</span>
<span class="pl-en">va_list</span>(values<span class="pl-k">...</span>) <span class="pl-k">=</span> <span class="pl-c1">va_list</span><span class="pl-c1">{()}</span>(values<span class="pl-k">...</span>)</pre></div>
<p dir="auto">thoughts? improvements? should I make a pull request?</p>