# Julian way to implement structs with different "defaults"?

**URL:** <https://discourse.julialang.org/t/julian-way-to-implement-structs-with-different-defaults/128046>\
**Category:** General Usage\
**Created:** [April 14, 2025, 7:09am UTC](https://discourse.julialang.org/t/julian-way-to-implement-structs-with-different-defaults/128046 "2025-04-14T07:09:03Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [April 14, 2025, 12:38pm UTC](https://discourse.julialang.org/t/julian-way-to-implement-structs-with-different-defaults/128046/6 "2025-04-14T12:38:07Z")

</div>

The whole idea is to have a struct where I have the same fields but different “defaults” where then users can change something punctual (a few parameters) relative to these “defaults”.

I am fine with your solution, I just need to find now a way to “automatically” get the keyword arguments of a function.

For example, in:

```julia
function foo(;
    x = 5,
    y = [10,20,30],
    z = x .+ (2 .* y) ,
    kwargs...)
    p = printme(;x=x,y=y,z=z,kwargs...) 
    return p
end
function printme(;kwargs...)
    for (k,v) in kwargs
        println("$k: $v")
    end
end
foo(;x=10, a=1,b="a")

```

How to avoid typing “x=x,y=y,z=z” ? Is there a macro that provides the keyword arguments (used or not) of a function ?

I can see this [old thread](https://discourse.julialang.org/t/get-the-argument-names-of-an-function/32902/3), but here I need it _inside_ the function itself, so using that method would lead likely to infinite recursion…

---

_[View the full topic](https://discourse.julialang.org/t/julian-way-to-implement-structs-with-different-defaults/128046)._
