<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">A few clarifying addenda:<div class=""><br class=""></div><div class="">1. the comment "// identical to x : Dictionary<String : Int> = ..." should be "// identical to x : Dictionary<String, Int> = ..."</div><div class=""><br class=""></div><div class="">2. For proposal #2, the compiler should require that all type parameter aliases declared on the LHS of the "=" be used when declaring the underlying type on the RHS of the "=".</div><div class=""><br class=""></div><div class="">3. For proposal #2, the only valid values for the type arguments when declaring the underlying type on the RHS of the "=" are type parameter aliases declared on the LHS, and valid concrete types.</div><div class=""><br class=""></div><div class="">Best,</div><div class="">Austin</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 4, 2015, at 9:57 PM, Austin Zheng <<a href="mailto:austinzheng@gmail.com" class="">austinzheng@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Perhaps we should "formalize" a proposal as a starting point for further discussion/development.<div class=""><br class=""></div><div class="">Currently, Swift supports defining an alias for an existing non-generic or fully bound generic type using the 'typealias' keyword:</div><div class=""><br class=""></div><div class="">typealias Foo = Int</div><div class="">typealias Bar = Dictionary<String : Int></div><div class=""><br class=""></div><div class="">In this example, the type referred to by the identifier 'Foo' is exactly equivalent to the existing type Int. Any occurrence of the type identifier "Int" can be replaced in a Swift source code text by the typealias identifier "Foo" without changing the behavior of the program.</div><div class=""><br class=""></div><div class="">When a typealias is defined, the underlying type can be the underlying type of another typealias:</div><div class=""><br class=""></div><div class="">typealias Baz = Foo // Baz is typealias of Int now</div><div class=""><br class=""></div><div class="">However, the typealias mechanism does not allow an unbound generic type to be typealiased:</div><div class=""><br class=""></div><div class="">// This fails</div><div class="">typealias MyArray = Array</div><div class="">// as does this</div><div class="">typealias MyArray<T> = Array<T></div><div class=""><br class=""></div><div class="">There are at least two potential ways to extend the typealias mechanism to support typealiasing unbound generic types.</div><div class=""><br class=""></div><div class="">1. Allow an unbound generic type to be directly typealiased to a different identifier. The alias can then be used in place of the original generic type identifier anywhere where the latter would have been valid, in such a way that a direct textual substitution of the original identifier for the new identifier (or vice versa) would not change the meaning of a Swift program.</div><div class=""><br class=""></div><div class="">typealias HashMap = Dictionary</div><div class="">let x : HashMap<String, Int> = ["hello" : 1234]<span class="Apple-tab-span" style="white-space:pre">        </span>// identical to x : Dictionary<String : Int> = ...</div><div class=""><br class=""></div><div class="">2. Allow an identifier to serve as a typealias to a partially specialized or fully unspecialized generic type. When declaring the typealias identifier, type parameter aliases can be declared as well within a generic type signature, akin to the "<>" generic type signature supported by type decls and function decls. When declaring the underlying type, unbound generic type parameters can then be bound to the type parameter aliases defined alongside the typealias identifier. Instead of an type parameter identifier, a concrete type can be used to partially specialize the type referred to by the typealias. For example:</div><div class=""><br class=""></div><div class="">typealias HomogenousDict<T> = Dictionary<T, T></div><div class="">// A declaration of HomogenousDict<Int> is exactly equivalent to a declaration of Dictionary<Int, Int>.</div><div class="">typealias DontDoThis<U, T> = Dictionary<T, U></div><div class="">// A declaration of DontDoThis<String, Int> is exactly equivalent to a declaration of Dictionary<Int, String>.</div><div class="">// This might be a potential issue.</div><div class="">typealias IntKeyDicts<Value> = Dictionary<Int, Value></div><div class="">// A declaration of IntKeyDicts<String> is then exactly equivalent to a declaration of Dictionary<Int, String></div><div class=""><br class=""></div><div class="">I hope this can serve as a starting point for discussion of the design of this feature, as well as identification of potential semantic and implementation issues.</div><div class=""><br class=""></div><div class="">Best,</div><div class="">Austin</div><div class=""><div class=""><br class=""></div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 4, 2015, at 8:35 PM, Douglas Gregor <<a href="mailto:dgregor@apple.com" class="">dgregor@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""><br class="">Sent from my iPhone</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class="">On Dec 4, 2015, at 4:08 PM, Joe Groff <<a href="mailto:jgroff@apple.com" class="">jgroff@apple.com</a>> wrote:<br class=""><br class=""></div><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 4, 2015, at 3:04 AM, Dapeng Gao <<a href="mailto:gdapeng@icloud.com" class="">gdapeng@icloud.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">It would be handy if Swift can support generic `typealias`s, which would probably look like this:<div class=""><br class=""></div><div class=""><div class="" style="margin: 0px; font-size: 18px; font-family: Menlo;"><span class="" style="color: rgb(195, 34, 117);">typealias</span><span class="Apple-converted-space"> </span>Handler<Element> = [Element] -> Void</div></div><div class=""><br class=""></div><div class="">One common way to achieve this is to define a generic `struct` and use a nested `typealias`:</div><div class=""><br class=""></div><div class=""><div class="" style="margin: 0px; font-size: 18px; font-family: Menlo;"><span class="" style="color: rgb(195, 34, 117);">struct</span><span class="Apple-converted-space"> </span>HandlerWrapper<Element> {</div><div class="" style="margin: 0px; font-size: 18px; font-family: Menlo;"> <span class="Apple-converted-space"> </span><span class="" style="color: rgb(195, 34, 117);">typealias</span><span class="Apple-converted-space"> </span>Hander = [<span class="" style="color: rgb(97, 34, 174);">Element</span>] -><span class="Apple-converted-space"> </span><span class="" style="color: rgb(112, 61, 170);">Void</span></div><div class="" style="margin: 0px; font-size: 18px; font-family: Menlo;">}</div></div><div class="" style="margin: 0px; font-size: 18px; font-family: Menlo;"><br class=""></div><div class="" style="margin: 0px; font-size: 18px; font-family: Menlo;"><div class="" style="margin: 0px; color: rgb(83, 154, 164);">HandlerWrapper<span class=""><</span><span class="" style="color: rgb(112, 61, 170);">SomeType</span><span class="">>.</span>Hander</div></div></div></div></blockquote><br class=""></div><div class="">Definitely. I'd say this falls under the (totally arbitrary) umbrella of "obvious things that we didn't get around to implementing yet" instead of formal changes to the language. If you (or anyone else!) were to implement this, we'd consider the pull request immediately.</div></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">I would rather not have such an umbrella, because how would one know what's in it and who gets to decide? Even "obvious" things need design, and some things that might sound like obvious goodness can benefit from review. ++ sounded like obvious goodness at one point in time, too. </div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""> - Doug</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=7XtDdMHRjqIUi4tzSjSp2pWQIyxYdP6woIWn4vwV5gfHtS1kWv6OOSz8Mn0H4E0EhnfqVNM2MdxKisnz8VVcAzkB67hL6uHzgOP3I-2FJMIhfoYod3fbHeMkBSDc-2BBeZ6uekapmGNEcz4bAH-2FOJJn-2FtpeqLPF6WLtKTA6vhAv93LlAiG9aDYCydTff7Hi-2Bh7kPZ9ynInukBOMdjzz594CAIpL5w7pKtkSjCSPZOLV1mw4-3D" alt="" width="1" height="1" border="0" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""><span class="Apple-converted-space"> </span></span><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">swift-evolution mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:swift-evolution@swift.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">swift-evolution@swift.org</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br class=""></div></div></div></div></blockquote></div><br class=""></div></body></html>