<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><br><br>Sent from my iPad</div><div><br>On May 10, 2016, at 5:41 PM, Timothy Wood <<a href="mailto:tjw@me.com">tjw@me.com</a>> wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html charset=utf-8"><br class=""><div><blockquote type="cite" class=""><div class="">On May 10, 2016, at 2:01 PM, Chris Lattner via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> 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. When is this concept important? 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<Owner, DataType>(...)<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></blockquote><div><br></div>Ahh, this is different than what I have been talking about as it statically evaluates at the call site rather than the declaration site. Sorry, I think I missed your earlier post.<div><br></div><div>One question about this - how would it work if this method was called in a lexical con txt without an enclosing type declaration? Would that be an error or would it just require a parameter to be passed?<br><div><br></div><div>If we call what I am talking about Type and we also want this behavior we should call it #Type as it would be the static type at the call site. But they are separate ideas and should be separate proposals.<div><div><br><blockquote type="cite"><div><div class=""><div class=""><br class=""></div></div><div class=""><br class=""></div><div class="">-tim</div><div class=""><br class=""></div></div></blockquote></div></div></div></div></body></html>