<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On May 10, 2016, at 2:01 PM, Chris Lattner via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">That said, I’m not sure I understand the concrete use-cases. &nbsp;When is this concept important? &nbsp;When is “Self” not good enough?</div></div></div></blockquote><div><br class=""></div></div>From my old mail on the subject:<div class=""><br class=""></div><div class=""><blockquote type="cite" class="">I would love to see a way to get the type of the "enclosing thing at compile time”. In my particular case, I’m using the type as a generic parameter to tag a created resource with something like:<br class=""><br class=""><blockquote class="" style="margin: 0px 0px 0px 40px; border: none; padding: 0px;">class Client: PropertyOwner {<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>let intProperty = Client.property(“name”, Int(0))<br class="">}</blockquote><br class="">where PropertyOwner has a static property&lt;Owner, DataType&gt;(...)<br class=""><br class="">With `Self` meaning the static version of the thing being compiled, I could at least write:<br class=""><br class=""><blockquote class="" style="margin: 0px 0px 0px 40px; border: none; padding: 0px;">class Client: PropertyOwner {<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>let intProperty = Self.property(“name”, Int(0))<br class="">}</blockquote><br class="">which would have the benefit of being harder to mess up due to copy-pasting between different PropertyOwner implementors.</blockquote></div><div class=""><br class=""></div><div class="">and</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class="">I was thinking about the syntax a bit further and it seems like the capability that would be added is like #file, in that it does some compile-time textual replacement. So, perhaps #Self would work?<div class=""><br class=""></div><div class="">Also, along these lines, I would find use for call-site interpolation like #file has. I could then do a free function version of my property() call that was something like:</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>func property(ownerType: PropertyOwner.Type = #Self, ...) { }</div><div class=""><br class=""></div><div class="">which would only be callable from w/in things conforming to or subclassing PropertyOwner.</div></blockquote></div><div class=""><div class=""><br class=""></div></div><div class=""><br class=""></div><div class="">-tim</div><div class=""><br class=""></div></body></html>