I filed a GitHub issue but it was suggested this might need to go through evolution.
Can file:line:-line default parameters be added to dynamic member lookup subscripts? It'd be super useful for surfacing the source context of an issue through to the dynamic caller in question.
22 Likes
Yonas_Kolb
(Yonas Kolb)
2
I would find this very useful too, big plus 1
3 Likes
Jon_Shier
(Jon Shier)
3
In general it would be nice to loosen the requirements around the dynamic member lookup. Right now it fails with subscript<T>(dynamicMember: KeyPath<Self, T>) but succeeds with subscript<T>(dynamicMember dynamicMember: KeyPath<Self, T>) which seems more specific than any other lookup I've seen. Being able to apply the general shape of the simple lookup with other defaulted parameters would be nice.
1 Like
Jumhyn
(Frederick Kellison-Linn)
4
Isn't this just a product of the fact that subscript<T>(dynamicMember: KeyPath<Self, T>) declares a subscript whose external name is subscript(_:)? You're allowed to rename the (inner) parameter name as you see fit for dynamic member lookup, so I wouldn't want it to be the case that any unlabeled subscript which accepts a String (or KeyPath) argument to be considered a 'match' for the purposes of dynamic member lookup.
4 Likes
Jon_Shier
(Jon Shier)
5
Ah yes, I forgot that the subscript naming rules are different from funcs.
2 Likes
Jumhyn
(Frederick Kellison-Linn)
6
Yeah, that's its own can of worms, taking the naming rules for subscripts as given I think the 'matching' here is behaving appropriately.
2 Likes
Beyond DML, I think it'd be nice to extend file:line: support to otherwise protocol conforming methods.
davedelong
(Dave DeLong)
8
This is very much related to the desire I've had for several years that operator functions should accept file: and line: for capturing point-of-use info.
2 Likes
jrose
(Jordan Rose)
9
This is the best argument I’ve seen thus far that these shouldn’t be represented as parameters, because the calling convention for a protocol method doesn’t have any place to put extra parameters. :-( Then again, sometimes you do want to propagate file/line info, so simply doing something besides parameters wouldn’t necessarily work either.
5 Likes