# Structure constructor

**URL:** <https://racket.discourse.group/t/structure-constructor/3748>\
**Category:** Questions & Answers\
**Created:** [May 18, 2025, 11:00pm UTC](https://racket.discourse.group/t/structure-constructor/3748 "2025-05-18T23:00:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hendrikboom3](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/hendrikboom3/32/2748_2.png) [@hendrikboom3](https://racket.discourse.group/u/hendrikboom3)\
**Post date:** [May 18, 2025, 11:00pm UTC](https://racket.discourse.group/t/structure-constructor/3748/1 "2025-05-18T23:00:50Z")

</div>

Let's define a structure type

(struct onion (leek cut tears))

Now I'd like to construct a value of this type. I can say

(onion 1 2 4)

but if there are a lot of components it can become obscure which value goes with which field.

Is there some syntax that lets me provide keyword arguments to the constructor? Something like  
onion cut: 3 tears: many leek: 1)  
Of course his likely isn't the correct syntax .

But is there any way of getting keywords like this in a constructor -- without of course hand-coding a special-purpose function with keyword arguments for each structure type.

Of course there's struct-copy, but that requires I first make dummy version of the structure to modify, which seems wasteful.

---

<div class="post-metadata">

**Author:** ![maueroats](https://avatars.discourse-cdn.com/v4/letter/m/c0e974/32.png) [@maueroats](https://racket.discourse.group/u/maueroats)\
**Post date:** [May 19, 2025, 12:27am UTC](https://racket.discourse.group/t/structure-constructor/3748/2 "2025-05-19T00:27:02Z")

</div>

Are you willing to use an add-on package like [struct-plus-plus](https://docs.racket-lang.org/struct-plus-plus/index.html)? That has keyword constructors.
