This is a style question, I already have a solution, just looking for opinions.
Sometimes I find it convenient to specify defaults with keyword arguments for a couple of functions, which are then invoked by some other function, where I don’t want to repeat the defaults. So I collect the keywords args with ...
, and pass them on. But I need to collect the unused ones in the functions that are called; anticipating #9343 I am doing it like this (MWE):
pick_a(; a = 5, _...) = a
pick_b(; b = 7, _...) = b
ab(; args...) = pick_a(; args...) + pick_b(; args...)
ab() # 12
ab(; a = 1) # 8
Is this an OK interface design? Are there any caveats?
(I know that for anything more serious I should wrap parameters up in a struct
, but that is sometimes too involved).