<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">+1 </div><div class=""><br class=""></div><div class="">can’t wait for the Generics 4.0:</div><div class=""><br class=""></div><div class=""><pre style="white-space: pre-wrap; background-color: rgb(255, 255, 255);" class="">++++ typealias StringDictionary<Value> = Dictionary<String, Value></pre></div><div class=""><pre style="white-space: pre-wrap; background-color: rgb(255, 255, 255);" class="">++++ Parameterized extensions</pre></div><div class=""><pre style="white-space: pre-wrap; background-color: rgb(255, 255, 255);" class="">+++ func containsAll<S: Sequence>(elements: S) -> Bool </pre><pre style="white-space: pre-wrap; background-color: rgb(255, 255, 255);" class=""> where Sequence.Iterator.Element == Element
</pre></div><div class=""><pre style="white-space: pre-wrap; background-color: rgb(255, 255, 255);" class="">++++++++++ Higher-kinded types</pre></div><div class=""><pre style="white-space: pre-wrap; background-color: rgb(255, 255, 255);" class="">+++ Generalized existentials
</pre></div><div class=""><pre style="white-space: pre-wrap; background-color: rgb(255, 255, 255);" class=""> Generic protocols</pre></div><div class="">The ConstructibleFrom<X> looks a bit like something I played with this afternoon:</div><div class=""><br class=""></div><div class=""><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">public</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">protocol</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> LiteralCreatable {</span></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;"> </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">associatedtype</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> LiteralType</span></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;"> </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">init</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(literalValue : LiteralType)</span></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">}</span></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">public</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">protocol</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> NilLiteralConvertible : </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">LiteralCreatable</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> {</span></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;"> </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">associatedtype</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> LiteralType = ()</span></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">}</span></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">public</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">protocol</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> StringLiteralCreatable : </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">LiteralCreatable</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> {</span></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;"> </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">associatedtype</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> LiteralType = String</span></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">}</span></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">public</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">protocol</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> IntLiteralCreatable : </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">LiteralCreatable</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> {</span></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;"> </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">associatedtype</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> LiteralType = Int</span></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">}</span></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;"><span class="" style="font-variant-ligatures: no-common-ligatures;"></span><br class=""></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;"><span style="font-family: Helvetica;" class="">Cheers,</span></div></div><div class="">L/</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Apr 14, 2016, at 3:41 AM, Joe Groff via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">It's been pitched before, but I don't think we've had a dedicated thread to this idea. Erica has proposed making `Self` generally available within methods in types to refer to the dynamic type of the current receiver. One could think of `Self` as a special associated type member that exists in every type for this purpose. This also happens to be what you get when ask for the `dynamicType` member of a value. We could unify these concepts and get rid of the clunky `dynamicType` keyword, replacing it with `x.Self`.<br class=""><br class="">There's another benefit to this syntax change. Looking to the future, one of the many features Doug pitched in his generics manifesto was to generalize protocol existentials, lifting our current restrictions on protocols "with Self or associated types" and allowing them to be used as dynamic types in addition to static generic constraints. Once you do this, you often want to "open" the type of the existential, so that you can refer to its Self and associated types in the types of other values. I think a natural way would be to let you directly use Self and associated type members of existentials as types themselves, for example:<br class=""><br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>let a: Equatable = /*...*/<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>let b: Equatable = /*...*/<br class=""><br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>// This is not allowed, since Equatable requires two values with the same static type, but<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>// a and b may have different dynamic types.<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>a == b <br class=""><br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>// However, we can dynamically cast one to the other's dynamic type:<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>if let bAsA = b as? a.Self {<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>return a == bAsA<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>}<br class=""><br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>let x: RangeReplaceableCollection = /*...*/<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>let y: Collection = /*...*/<br class=""><br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>// If y has the same dynamic Element type as x, append it to x<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>var z: x.Self = x<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>if let yAsX = y as? Any<Collection where Element == x.Element> {<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>z.append(yAsX)<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>}<br class=""><br class="">`x.Self` then becomes just the first step in this direction.<br class=""><br class="">-Joe<br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></div></blockquote></div><br class=""></body></html>