# Keyword Arguments vs Dict

**URL:** <https://discourse.julialang.org/t/keyword-arguments-vs-dict/33500>\
**Category:** General Usage\
**Tags:** question\
**Created:** [January 17, 2020, 6:31pm UTC](https://discourse.julialang.org/t/keyword-arguments-vs-dict/33500 "2020-01-17T18:31:43Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Jakub\_Wronowski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jakub_wronowski/32/204030_2.png) [@Jakub\_Wronowski](https://discourse.julialang.org/u/Jakub_Wronowski)\
**Post date:** [January 17, 2020, 10:12pm UTC](https://discourse.julialang.org/t/keyword-arguments-vs-dict/33500/4 "2020-01-17T22:12:59Z")

</div>

I’m not able to judge your preferences without more context. My personal opinion is that dictionaries should be avoided due to their lack of performance and elegance. Value tuples and named keyword arguments are better for me, for instance they allow autocompletion in code editor.  
If your model is really complicated and have some business rules you need to validate I would define some struct, maybe some hierarchy of structs (you can go abstract types or nested structs, or both). Probably your params have some defaults in case of missing user input. We had quite interesting discussion in thread below about default values for fields. There are also other threads about this topic.  
We can always define some macros if you have an idea for better syntax for handling that, user input in scripts is a common problem I am also struggling.

> [@Default value of \*some\* fields in a mutable struct](https://discourse.julialang.org/t/default-value-of-some-fields-in-a-mutable-struct/33408/18):
>
> Are you looking for something like this? mutable struct coly\_xy x :: Int32 y :: Float64 z :: Bool t :: Int32 u :: Float32 v :: Bool function coly\_xy(;kwargs...) K = new() for (key, value) in kwargs setfield!(K, key, value) end return K end end It allows you to specify the fields you want to set by name. julia\> coly\_xy(t=Int32(13), v=true) coly\_xy(1, 1.0e-323, false, 13, 3.9061288f-19, true) For more convenience you …

---

_[View the full topic](https://discourse.julialang.org/t/keyword-arguments-vs-dict/33500)._
