# Using \`...\` syntax and \`--trim\`

**URL:** <https://discourse.julialang.org/t/using-syntax-and-trim/133201>\
**Category:** General Usage\
**Tags:** juliac, trim, trimming\
**Created:** [October 16, 2025, 10:42am UTC](https://discourse.julialang.org/t/using-syntax-and-trim/133201 "2025-10-16T10:42:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![apozharski](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@apozharski](https://discourse.julialang.org/u/apozharski)\
**Post date:** [October 16, 2025, 10:42am UTC](https://discourse.julialang.org/t/using-syntax-and-trim/133201/1 "2025-10-16T10:42:57Z")

</div>

Hello,

I am working on a package for building c interfaces for an NLP solver packages and have run into something of an impasse regarding the `--trim` functionality and calling functions with keyword arguments which need to be populated at run time.

The situation is this: I have a `options::T` where `T <: AbstractDict{Symbol, Union{<Some stuff>}}`, populated by the c user at run time, which contains the keyword arguments I would like to pass to the constructor of the underlying options type. However, it seems that none of the obvious ways (that is `...`) interact well with the `--trim=safe` flag in `JuliaC.jl`, and run into issues with unresolved calls to `_apply_iterate` (I assume related to [Support resolving dispatch in `apply_iterate` for variable-length containers (`Tuple{Vararg{T}}` and `Vector{T}`) · Issue #57830 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/57830)).

Is there _any_ way to use the `...` syntax and retain the ability to use `--trim`? Am I missing something?

---

<div class="post-metadata">

**Author:** ![abraemer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abraemer/32/51403_2.png) [@abraemer](https://discourse.julialang.org/u/abraemer)\
**Post date:** [October 17, 2025, 8:24pm UTC](https://discourse.julialang.org/t/using-syntax-and-trim/133201/2 "2025-10-17T20:24:59Z")

</div>

I am not an expert in AOT compilation but I suspect that the underlying issue is that splatting aka `...` is oftentimes type unstable. Consider this:

```julia-auto
function foo()
    vec = [1, 2, 3]
    +(vec...) # type unstable
end

```

Why is this type unstable? Because the vector does not carry its length as type parameter. So when Julia compiles this, fhe compiler has no idea how many arguments the function `+` will receive and thus does not know which method it needs to dispatch to. So it has to use a dynamic dispatch.

The matter is different when you use a tuple or `StaticVector` that carry size information in the type. Then splatting is type stable.

---

<div class="post-metadata">

**Author:** ![cjdoris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cjdoris/32/213133_2.png) [@cjdoris](https://discourse.julialang.org/u/cjdoris)\
**Post date:** [October 18, 2025, 12:22pm UTC](https://discourse.julialang.org/t/using-syntax-and-trim/133201/3 "2025-10-18T12:22:01Z")

</div>

Basically no, because it is type-unstable.

I think your best bet is to explicitly get the options at the call site, something like

```julia-auto
foo(
    # required option
    opt1=options[:opt1]::Int,
    # optional option with default
    opt2=get(options, :opt2, nothing)::Union{Float64,Nothing}
)

```

---

<div class="post-metadata">

**Author:** ![apozharski](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@apozharski](https://discourse.julialang.org/u/apozharski)\
**Post date:** [October 20, 2025, 9:37am UTC](https://discourse.julialang.org/t/using-syntax-and-trim/133201/4 "2025-10-20T09:37:30Z")

</div>

@abraemer Thanks, I knew this is type unstable in cases of variadic numbers of parameters (like `+(args...)`) and it makes sense there is no way around this. It however does not make a lot of sense to me why it contributes to type instability in keyword arguments as, as far as I understand, these are not specialized on. Unfortunately your suggestions are not (easily) feasible for me as the creation of the options structure crosses the Julia-C boundary.

@cjdoris This is probably actually possible! Unfortunately it is quite annoying as there is no particularly sane way to get defaults (meta-)programmatically from a `@kwdef`ed struct but this is a good direction to go in.

Thanks for the ideas!

---

<div class="post-metadata">

**Author:** ![cjdoris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cjdoris/32/213133_2.png) [@cjdoris](https://discourse.julialang.org/u/cjdoris)\
**Post date:** [October 20, 2025, 10:20am UTC](https://discourse.julialang.org/t/using-syntax-and-trim/133201/5 "2025-10-20T10:20:04Z")

</div>

> [@apozharski](#):
>
> there is no particularly sane way to get defaults (meta-)programmatically from a `@kwdef`ed struct

You could make an instance and get its fields like

```julia-auto
const MY_DEFAULTS = MyStruct()

foo(opt1=get(options, :opt1, MY_DEFAULTS.opt1), ...)

```
