<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="">It’s just placeholder syntax for ‘a value whose type is given by a generic parameter in the following signature’.<div class=""><br class=""></div><div class="">Slava</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Sep 5, 2017, at 4:44 AM, Rudolf Adamkovič &lt;<a href="mailto:salutis@me.com" class="">salutis@me.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I see. TBH, I don’t understand why it says “Any” in the "generalized existentials” but everything else is clear.&nbsp;</div><div class=""><br class=""></div><div class="">Thank you Slava!</div><div class=""><br class=""></div><div class="">R+</div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 5 Sep 2017, at 01:52, Slava Pestov &lt;<a href="mailto:spestov@apple.com" class="">spestov@apple.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Rudolf,<div class=""><br class=""></div><div class="">What you are describing is not possible right now. The protocol PointType cannot be used as a type at all, because it has an associated type requirement. Also it is not clear what a ‘where’ clause attached to a type alias would mean.</div><div class=""><br class=""></div><div class="">There has been some discussion of ‘generalized existentials’ on the evolution list. So eventually, you might be able to say something like this:</div><div class=""><br class=""></div><div class="">typealias Point = Any&lt;Point : PointType where Point.Float == Float&gt;</div><div class=""><br class=""></div><div class="">Slava</div><div class=""><br class=""><div class=""><div class=""><blockquote type="cite" class=""><div class="">On Sep 4, 2017, at 6:12 PM, Rudolf Adamkovič via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I have the following&nbsp;<span style="font-family: Menlo; font-size: 14px; background-color: rgb(255, 255, 255);" class="">ProceduralDrawing</span>&nbsp;type:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">public</span> <span style="color: #ba2da2" class="">struct</span> ProceduralDrawing&lt;Float, Point: <span style="color: #4f8187" class="">PointType</span>&gt; <span style="color: #ba2da2" class="">where</span> <span style="color: #4f8187" class="">Point</span>.<span style="color: #703daa" class="">Float</span> == <span style="color: #4f8187" class="">Float</span> {</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);" class=""><span style="" class="">&nbsp; &nbsp;&nbsp;</span>// ... code that used Float and Point ...</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">}</div></div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);" class="">public<span style="" class=""> </span>protocol<span style="" class=""> PointType {</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);" class=""><span style="" class="">&nbsp; &nbsp; </span>associatedtype<span style="" class=""> Float: </span><span style="color: #703daa" class="">FloatingPoint</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; <span style="color: #ba2da2" class="">var</span> x: <span style="color: #703daa" class="">Float</span> { <span style="color: #ba2da2" class="">get</span> }</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; <span style="color: #ba2da2" class="">var</span> y: <span style="color: #703daa" class="">Float</span> { <span style="color: #ba2da2" class="">get</span> }</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">}</div></div><div class=""><br class=""></div><div class="">I would like to avoid adding&nbsp;<span style="font-family: Menlo; font-size: 14px; background-color: rgb(255, 255, 255);" class="">Point</span>&nbsp;as a generic parameter but the following doesn’t work:</div><div class=""><span style="font-family: Menlo; font-size: 14px; background-color: rgb(255, 255, 255);" class=""><br class=""></span></div><div class=""><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: rgb(186, 45, 162);" class="">public</span>&nbsp;<span style="color: rgb(186, 45, 162);" class="">struct</span>&nbsp;ProceduralDrawing&lt;Float:&nbsp;<span style="color: rgb(112, 61, 170);" class="">FloatingPoint</span>&gt; {</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);" class=""><span style="" class="">&nbsp; &nbsp;&nbsp;</span>// ERROR: 'where' clause cannot be attached to a non-generic declaration</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp;&nbsp;<span style="color: rgb(186, 45, 162);" class="">typealias</span>&nbsp;Point =&nbsp;<span style="color: rgb(79, 129, 135);" class="">PointType</span>&nbsp;<span style="color: rgb(186, 45, 162);" class="">where</span>&nbsp;Point.Float == Float</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);" class=""><span style="" class="">&nbsp; &nbsp;&nbsp;</span>// ... code that uses Float and Point ...</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">}</div></div><div class=""><br class=""></div><div class="">Is there a way to do this? If not, why?</div><div class=""><br class=""></div><div class="">Thanks!</div><div class=""><br class=""></div><div class="">R+</div></div>_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-users" class="">https://lists.swift.org/mailman/listinfo/swift-users</a><br class=""></div></blockquote></div><br class=""></div></div></div></div></blockquote></div><br class=""></div></div></blockquote></div><br class=""></div></body></html>