<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="">I have the following <span style="font-family: Menlo; font-size: 14px; background-color: rgb(255, 255, 255);" class="">ProceduralDrawing</span> 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<Float, Point: <span style="color: #4f8187" class="">PointType</span>> <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="color: rgb(0, 0, 0);" class=""> </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="color: #000000" class=""> </span>protocol<span style="color: #000000" 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="color: #000000" class=""> </span>associatedtype<span style="color: #000000" 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=""> <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=""> <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 <span style="font-family: Menlo; font-size: 14px; background-color: rgb(255, 255, 255);" class="">Point</span> 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> <span style="color: rgb(186, 45, 162);" class="">struct</span> ProceduralDrawing<Float: <span style="color: rgb(112, 61, 170);" class="">FloatingPoint</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="color: rgb(0, 0, 0);" class=""> </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=""> <span style="color: rgb(186, 45, 162);" class="">typealias</span> Point = <span style="color: rgb(79, 129, 135);" class="">PointType</span> <span style="color: rgb(186, 45, 162);" class="">where</span> 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="color: rgb(0, 0, 0);" class=""> </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></body></html>