I’m curious why the keyword arguments are available wrapped in Iterators.Pairs
in the function body:
function f(; kwargs...)
# kwargs is a NamedTuple wrapped in an Iterators.Pairs
end
Is it legacy cruft from a time when named tuple were not so nice? Because to me it seems simpler and more useful to expose the named tuple directly.
Simpler: named tuples are well known. Users don’t need to learn another collection type. For key-value iteration we would write pairs(kwargs)
which seems better to me (more explicit, and it reinforces the good pattern of using pairs
where appropriate).
More useful: because named tuples have a richer API. For example I can get the list of values with values(nt)
. Here I need the awkward and counter-intuitive values(values(kwargs))
.