The hack seems fine. The name field is exposed to take in symbols so that people can programmatically name things. I personally think such a macro extension would be overkill, but no reason to not make one.
Didn’t know that…
Seems that creating identical components is fine, though:
julia> @named y[1:3] = foo(x)
3-element Vector{NamedTuple{(:i, :name), Tuple{Int64, Symbol}}}:
(i = 41, name = :y_1)
(i = 41, name = :y_2)
(i = 41, name = :y_3)
But as you say:
@named y 1:10 i -> foo(x*i) # This is not recommended
It’s just kind of a hack given how the @named macro is implemented. It’s kind of surprising it works, since it just grabs the args at the highest level and slaps name = $y in there.