<div dir="ltr">It's not the same topic. Let's take an example: suppose we have a data structure for a graph of nodes and edges, where the nodes and edges are indexed and both have values. So we have a Graph<NodeIndex : Hashable, EdgeIndex : Hashable, NodeValue, EdgeValue>.<div>Now suppose we want a shortest path from one node to another, and we have a data structure to represent that. Now we have a Path<NodeIndex : Hashable, EdgeIndex : Hashable, NodeValue, EdgeValue>. They both have the same 'generic signature'. If you're navigating a Graph<String, Int, City, Motorway>, you're going to want a Path<String, Int, City, Motorway> as output.</div><div><br></div><div>Right now you might write that as:</div><div>func shortestPath<NodeIndex, EdgeIndex, NodeValue, EdgeValue>(graph:Graph<NodeIndex, EdgeIndex, NodeValue, EdgeValue>, startNode: NodeIndex, endNode: NodeIndex> -> Path<NodeIndex, EdgeIndex, NodeValue, EdgeValue></div><div><br></div><div>It might save a fair amount of typing if we had a generic equivalent to both typealias and associatedtype.</div><div><br></div><div>associatedgenerics GraphElements = <NodeIndex : Hashable, EdgeIndex : Hashable, NodeValue, EdgeValue></div><div>func shortestPath<GraphElements>(graph: Graph<GraphElements>, startNode<GraphElements.NodeIndex>, endNode<GraphElements.NodeIndex>) -> Path<GraphElements></div><div><br></div><div>genericalias NavigationGraphElements = GraphElements<String, Int, City, Motorway></div><div><br></div><div>typealias NavigationGraph = Graph<NavigationGraphElements></div><div>// navigationGraph.shortestPath() now returns a Path<NavigationGraphElements></div><div>// this last part is closest to the proposal under review.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 6, 2016 at 9:05 PM, Milos Rankovic via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Chris Lattner has a <a href="https://github.com/apple/swift-evolution/blob/master/proposals/0048-generic-typealias.md" target="_blank">proposal under review</a> on this topic. <div><br></div><div>milos<br><div><br></div><div><div><blockquote type="cite"><div><div class="h5"><div>On 6 Apr 2016, at 20:41, James Campbell via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br></div></div><div><div><div class="h5"><div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">This was inspired from the topic about moving where clauses out of parameter lists.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">Certain generics get very long winded, I was wondering if we could create some sort of alias for generics.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px">func anyCommonElements <T: SequenceType, U: SequenceType where T.Generator.Element: Equatable, T.Generator.Element == U.Generator.Element> (lhs: T, _ rhs: U) -> Bool</span><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px"><br></span></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px">could be shared across functions like so:</span></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px"><br></span></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px">genericalias SequencesWithSameElements<T, U> = </span><span style="font-size:12.8px;font-family:arial,sans-serif;color:rgb(34,34,34)"><T: SequenceType, U: SequenceType where T.Generator.Element: Equatable, T.Generator.Element == U.Generator.Element></span></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px"><br></span></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px">func anyCommonElements <</span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px">SequencesWithSameElements</span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px">> (lhs: T, _ rhs: U) -> Bool</span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px"><br></span></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px">func == <</span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px">SequencesWithSameElements</span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px">> (lhs: T, _ rhs: U) -> Bool</span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px"><br></span></div><div><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><p><b><font color="#cc0000">___________________________________</font></b></p><p><b>James⎥</b></p><p><b><font color="#cc0000"><a href="mailto:james@supmenow.com" target="_blank">james@supmenow.com</a>⎥<a href="http://supmenow.com/" target="_blank">supmenow.com</a></font></b></p><p><b><font size="2">Sup</font></b></p><p><b><font size="2">Runway East
</font></b></p><p><b><font size="2">10 Finsbury Square</font></b></p><p><b><font size="2">London</font></b></p><p><b><font size="2">
EC2A 1AF </font></b></p></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
</div></div></div>
_______________________________________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div></blockquote></div><br></div></div></div><br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></div>