Yeah, I agree with you here. I think the thing we considered was that we don't want the easy API to be able to easily vend these mutable keypaths without any way of opting in/out.
We could make an API to get a field from name, however the implementation would still need to iterate the list of fields to find the specific field (just like how one would do it now). However, unlike Mirror
, iterating the collection of Fields
is significantly faster because of some of the performance benefits I mentioned when comparing Mirror
(and all of the collection wrappers are RandomAccessCollection
). All of the APIs on Field
are lazily retrieved unlike the children of Mirror
. @Karoy_Lorentey mentioned an API synopsis for things like these collections wrappers that I would be more than happy to add.
A lot about variadic generics is still unknown at the runtime layer besides what @John_McCall posted here: ABI for variadic generics, so I'm unsure how it'll look and interact with the language at runtime for reflection purposes. That being said, I plan to support variadic generics however much I can with these new APIs (or propose new APIs if it makes sense).