I want to revisit some specific generics idea that, IIRC, were generally
well-recieved at the time, but the conversation died down and nobody got around
to writing formal proposals. I want to revisit them now (as opposed to in phase
2) because I don’t know how much “growing room” there is in the ABI for
generics to gain features. It’d be a shame to close the door on these simply
because nobody said anything. Anyway...
1) Allow generic parameters to have optional labels: struct Array <Element T>
{…} //`let x = Array<Element: Double>` Not the best example, though, since I’d
definitely argue against adding a label here
2) Allow literals as generic arguments: struct Array <T,
Length: Int> {…} //Allows for `let x = Array<Double, Length: 10>()`
3) Allow generic parameters to have default values: struct Array <T, Length:
Int, FixedSize: Bool = false> {…} //The `let x…` from above still works, as
well as `let y = Array<Double, Length: 10, FixedSize: true>()`
In addition to concerns regarding binary backwards compatibility, there’s one
part where it might affect source code compatibility, too… If generic arguments
get optional labels, would we need to use a `_` like with function arguments to
indicate that we don’t intend for a label? Personally, I think a better
solution would be to just make the labels be the same as the parameter name and
have their use be optional altogether (except for parameters with default
values — those would always need labels in case the type has several and you
skip some), but perhaps others will feel differently.
Anyway, if this is phase 1 material, I’ll cheerfully get a informal proposal
written up to kick off the discussion thread. If not, I’ll shelve them until
phase 2.
- Dave Sweeris_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution