Flexible design to extend or remove kwarg in functions

Some useful options are shown at

The suggestion to package large numbers of kwargs into a struct makes sense to me.
I also like the “merge defaults” pattern:

function foo(; kwargs...)
   # Note that `x = 17` works as well as `:x => 17`
   defaults = (x = 17, );
   args = merge(defaults, kwargs);
   println(args[:x])
   # Or call another function `bar(; args...)`
end
2 Likes