EponymTuples.@eponymargs
— Macro@eponymargs(a, b::T, ...)
Expands to form like ((a, b)::NamedTuple{(:a, :b), <: Tuple{Any, T}})
, using the variable names both for the NamedTuple
and deconstruction in the function arguments.
Valid arguments are variable names, or names followed by a type specifier (when missing, Any
is used).
Example
julia> using EponymTuples
julia> foo(@eponymargs(a, b)) = a + b
foo (generic function with 1 method)
julia> foo((a = 1, b = 2))
3
EponymTuples.@eponymtuple
— Macro@eponymtuple(a, b = bval, ...)
Expands to (a = a, b = bval, ...)
, creating a named tuple.
Each argument is either a symbol, resulting in assigning its own value, or an assignment, passed as is.
The recommended use is the first one, allowing the creation of named tuples without repeating the name. Overriding the value is just for convenience, if you are using it too much you are probably better off with the standard NamedTuple
constructor (a = aval, b = bval, ...)
.