[swift-evolution] Idea: Let Generic Parameters Have Labels & Default Values

Jordan Rose jordan_rose at apple.com
Mon Jan 25 16:08:01 CST 2016


> On Jan 23, 2016, at 19:18, Andrew Bennett via swift-evolution <swift-evolution at swift.org> wrote:
> 
> I like the idea.
> 
> I think I'd be using typealias a lot to make things more concise, but that's not necessarily a problem. 
> 
> How would I name the following parameter?
> 
>     struct OrderedCollection<T: Comparable> {
>     }
> 
> As I understand it, would I do it as follows?
> 
>     struct OrderedCollection<Element: T: Comparable> {
>     }
> 
> Or would all type constraints now require `where`, like this:
>     struct OrderedCollection<Element: T where T: Comparable> {
>     }
> 
> Also, a typealias seems somewhat redundant when the parameter is labelled:
> 
>     struct OrderedCollection<Element: T where T: Comparable> {
>         typealias Element = T
>     }
> 
> I wonder if the typealias could be implied.

Without commenting on anything else, IIRC we were already planning to make the local typealias implied, even for today's generic parameters.

Jordan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160125/feb273d4/attachment.html>


More information about the swift-evolution mailing list