[swift-evolution] Generic Alaises

James Campbell james at supmenow.com
Wed Apr 6 14:41:10 CDT 2016


This was inspired from the topic about moving where clauses out of
parameter lists.

Certain generics get very long winded, I was wondering if we could create
some sort of alias for generics.

func anyCommonElements <T: SequenceType, U: SequenceType where
T.Generator.Element: Equatable, T.Generator.Element == U.Generator.Element>
(lhs: T, _ rhs: U) -> Bool

could be shared across functions like so:

genericalias SequencesWithSameElements<T, U> =  <T: SequenceType, U:
SequenceType where T.Generator.Element: Equatable, T.Generator.Element ==
U.Generator.Element>

func anyCommonElements <SequencesWithSameElements> (lhs: T, _ rhs: U) ->
Bool
func == <SequencesWithSameElements> (lhs: T, _ rhs: U) -> Bool

*___________________________________*

*James⎥*

*james at supmenow.com <james at supmenow.com>⎥supmenow.com <http://supmenow.com>*

*Sup*

*Runway East *

*10 Finsbury Square*

*London*

* EC2A 1AF *
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160406/56c45b65/attachment.html>


More information about the swift-evolution mailing list