# Constructor with type parameters and keywords

**URL:** <https://discourse.julialang.org/t/constructor-with-type-parameters-and-keywords/90244>\
**Category:** General Usage\
**Tags:** question\
**Created:** [November 14, 2022, 3:30pm UTC](https://discourse.julialang.org/t/constructor-with-type-parameters-and-keywords/90244 "2022-11-14T15:30:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [November 14, 2022, 3:30pm UTC](https://discourse.julialang.org/t/constructor-with-type-parameters-and-keywords/90244/1 "2022-11-14T15:30:07Z")

</div>

Suppose I have a constructor with some type parameters that **do not correspond to fields** , which I would like to determine automatically, in addition to getting the rest from keywords. Eg

```julia
Base.@kwdef struct Foo{K,T}
    x::T
end

Foo{3}(; x = 9.0) # want this to work

```

I am aware that I could just define

```julia
Foo{K}(; x::T) where {K,T} = Foo{K,T}(; x)

```

but manually enumerating arguments becomes tedious when there are many fields and defeats the convenience of the keyword constructor.

A convenient solution, which would not require enumerating all fields again, would be nice.
