[swift-evolution] Introduce "associated_type" keyword
David Waite
david at alkaline-solutions.com
Sat Dec 5 20:49:06 CST 2015
However, if a protocol wished to use type aliases not as part of a contract but for clarity, this would still need to be defined within the protocol in order for the associated types to be used in the typealias declarations.
-DW
> On Dec 5, 2015, at 7:29 PM, Dmitri Gribenko via swift-evolution <swift-evolution at swift.org> wrote:
>
> On Sat, Dec 5, 2015 at 6:27 PM, Loïc Lecrenier <loiclecrenier at icloud.com> wrote:
>> Great :)
>>
>> Also, this hasn't been explicitly discussed yet. But do you all agree about adding "real" typealias declarations (with the typealias keyword) inside protocols?
>
> Concrete typealieases are not requirements, so they shouldn't be
> defined inside of a protocol. Instead, they should be defined in the
> protocol extension. In fact, this has been a plan of record for some
> time, but it wasn't implemented.
>
> extension SequenceType {
> typealias Element = Generator.Element
> }
>
> Dmitri
>
> --
> main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
> (j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4139 bytes
Desc: not available
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151205/c16cedd6/attachment.p7s>
More information about the swift-evolution
mailing list