So, I don't personally think that _.zero should mean the same thing as .zero. That was my initial reaction to the _.zero form ("oh, that would just be another way to spell implicit member expressions, hmm"), but as I worked on the implementation I realized why they weren't immediately equivalent. I mentioned them in the update post in case anyone had read the earlier posts and come away with the impression that those two expressions would be equivalent.
I only brought it up again because of your suggestion that there's no logical grounds to allow _.self but not permit other members to hang off of _. I was trying (not super well, obviously) to communicate that:
There are logical reasons, based solely on current type inference rules (which this proposal does not modify), why _.self would work but, say, _.zero wouldn't, and
If there's a common intuition that _.zeroshould work, despite the above inference rules, then there are potentially ways to update those inference rules to allow such expressions to work as 'expected'.
The proposal and implementation have both been updated to reflect the decision to subset out top-level placeholders from this feature and leave them as a potential future direction pending further use and discussion of the feature.
Is this going to help with nested tuple destructuring? Swift is unable to fully destructure a nested tuple, for example when passing a closure to a Sequence.map where the sequence element is something like (A, (B, C)); to achieve a "faux-destructing" you can do something like this:
This works, I guess, because (Int, (Any, Bool)) is a supertype of (Int, (String, Bool)). Will I be able, with this proposal, to skip the Any and the Bool explicit type annotation and write something like this?
I donât think this can be considered valid: The first line of code is sufficient for the type inference to figure out that the placeholder should be Int, so anyArray = ["string"] should not be allowedâŚ
@wilsony Sorry if the text above was unclearâthis was meant as an example of a proposed alternative meaning for _ in types (which this proposal rejects). Under this proposal the quoted code is indeed invalid.
@Xkinler Sorry if the text above was unclearâthis was meant as an example of a proposed alternative meaning for _ one types which this proposal rejects. Under this proposal the quoted code is indeed invalid.