<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 Apr 20, 2016, at 11:16 AM, Chris Lattner via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Hello Swift community,</div><div class=""><br class="">The review of "SE-0068: Expanding Swift&nbsp;Self&nbsp;to class members and value types" begins now and runs through April 25. The proposal is available here:</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span><a href="https://github.com/apple/swift-evolution/blob/master/proposals/0068-universal-self.md" class="">https://github.com/apple/swift-evolution/blob/master/proposals/0068-universal-self.md</a><br class=""></div></div></div></blockquote></div><div class=""><br class=""></div><div class=""><b class="">RELATED DISCUSSIONS</b></div><div class=""><br class=""></div><div class="">*&nbsp;<a href="http://article.gmane.org/gmane.comp.lang.swift.evolution/15009" class="">Design Team feedback</a>&nbsp;on SE-0068</div><div class="">*&nbsp;<a href="http://thread.gmane.org/gmane.comp.lang.swift.evolution/13708" class="">[Pitch] Adding a Self type name shortcut for static member access</a></div><div class=""><div class="">*&nbsp;<a href="http://thread.gmane.org/gmane.comp.lang.swift.evolution/14445" class="">[Pitch] Rename `x.dynamicType` to `x.Self`</a></div><div class="">*&nbsp;<a href="http://thread.gmane.org/gmane.comp.lang.swift.evolution/9059" class="">Making `.self` after `Type` optional</a></div><div class="">*&nbsp;<a href="http://thread.gmane.org/gmane.comp.lang.swift.evolution/14173" class="">Remove the Need for 'self' to Access 'dynamicType'</a></div><div class=""><br class=""></div></div><div class=""><b class="">SHOULD .self BE REMOVED FROM TYPES</b></div><div class=""><b class=""><br class=""></b></div><div class="">Design team notes say:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><span style="color: rgb(51, 51, 51); font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; text-align: justify;" class="">We have a proposal to remove&nbsp;</span><tt class="literal docutils" style="color: rgb(51, 51, 51); font-size: 1em; text-align: justify; background-color: rgb(226, 226, 226);"><span class="pre">.self</span></tt><span style="color: rgb(51, 51, 51); font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; text-align: justify;" class="">&nbsp;on types. One reason&nbsp;</span><tt class="literal docutils" style="color: rgb(51, 51, 51); font-size: 1em; text-align: justify; background-color: rgb(226, 226, 226);"><span class="pre">.self</span></tt><span style="color: rgb(51, 51, 51); font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; text-align: justify;" class="">&nbsp;exists is to avoid the mistake of writing&nbsp;</span><tt class="literal docutils" style="color: rgb(51, 51, 51); font-size: 1em; text-align: justify; background-color: rgb(226, 226, 226);"><span class="pre">let</span>&nbsp;<span class="pre">x</span>&nbsp;<span class="pre">=</span>&nbsp;<span class="pre">Int</span></tt><span style="color: rgb(51, 51, 51); font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; text-align: justify;" class="">&nbsp;— the compiler will give you a weird type error later on in code if the value of&nbsp;</span><tt class="literal docutils" style="color: rgb(51, 51, 51); font-size: 1em; text-align: justify; background-color: rgb(226, 226, 226);"><span class="pre">x</span></tt><span style="color: rgb(51, 51, 51); font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; text-align: justify;" class="">&nbsp;is what we today call&nbsp;</span><tt class="literal docutils" style="color: rgb(51, 51, 51); font-size: 1em; text-align: justify; background-color: rgb(226, 226, 226);"><span class="pre">Int.self</span></tt><span style="color: rgb(51, 51, 51); font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; text-align: justify;" class="">&nbsp;but you meant to call the&nbsp;</span><tt class="literal docutils" style="color: rgb(51, 51, 51); font-size: 1em; text-align: justify; background-color: rgb(226, 226, 226);"><span class="pre">Int()</span></tt><span style="color: rgb(51, 51, 51); font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; text-align: justify;" class="">&nbsp;initializer. Creating a metatype is not a common operation, so doing it explicitly is a good thing.</span></div><div class=""><span style="color: rgb(51, 51, 51); font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; text-align: justify;" class=""><br class=""></span></div><div class=""><span style="color: rgb(51, 51, 51); font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; text-align: justify;" class="">Coming back to this proposal, if we removed&nbsp;</span><tt class="literal docutils" style="color: rgb(51, 51, 51); font-size: 1em; text-align: justify; background-color: rgb(226, 226, 226);"><span class="pre">.self</span></tt><span style="color: rgb(51, 51, 51); font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; text-align: justify;" class="">&nbsp;why would we want to add&nbsp;</span><tt class="literal docutils" style="color: rgb(51, 51, 51); font-size: 1em; text-align: justify; background-color: rgb(226, 226, 226);"><span class="pre">.Self</span></tt><span style="color: rgb(51, 51, 51); font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; text-align: justify;" class="">?</span></div></blockquote><div class=""><b class=""><br class=""></b></div><div class="">Background:</div><div class=""><ul class="MailOutline"><li class="">From Joe Groff: "`.self` is also a bit of load-bearing duct-tape that currently supports some other parsing aspects of Swift's syntax."&nbsp;</li><li class="">Jordan Rose adds, "Swift's type-checking engine is strong enough to merit not needing the redundant `.self` safety check."&nbsp;</li></ul></div><div class=""><br class=""></div><div class="">I personally like distinguishing `Type.self` from raw `Type` use for the reasons stated. This feature affirmatively prevents the use of `Typename` when `Typename()` is meant. In terms of this proposal, can this and should this be &nbsp;retained in the language but renamed from `self`? That would update the quiz to:</div><div class=""><br class=""></div><div class=""><pre class="" style="color: rgb(51, 51, 51); overflow-x: auto; overflow-y: hidden; border: thin dotted rgb(12, 55, 98); margin-top: 0px; margin-bottom: 12px; padding: 0.8em; background-color: rgb(240, 240, 240);"><span class="n">Self</span><span class="o" style="color: rgb(102, 102, 102);">.&lt;runcible&gt; // T.Type</span>
<span class="bp" style="color: rgb(0, 112, 32);">self</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="n">Self       // T.Type</span>
<span class="n">Self</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="n">Self       // T.Type.Type</span>
<span class="bp" style="color: rgb(0, 112, 32);">self</span><span class="o" style="color: rgb(102, 102, 102);">.&lt;runcible&gt; // == self</span></pre><div class="">Which reduces at least some of the confusion. The actual runcible name could be bikeshedded.</div></div><div class=""><br class=""></div><div class=""><b class="">IS `Self` THE RIGHT NAME? /&nbsp;</b><b class="">SHOULD `dynamicType` require `self`</b></div><div class=""><br class=""></div><div class="">I like `Self`. &nbsp;It is an existing keyword. It matches the approach used in protocols where `Self` is a placeholder for the type that conforms to that protocol. Under SE-0068, it refers to the dynamic type of the current instance. If it has to be a choice of one or the other, I'd prefer renaming `.self` and retaining `Self`. If `Self` is not the right name, I'd recommend either the `dynamictype` keyword and dropping the `self` prefix requirement <i class="">or</i>&nbsp;using a freestanding `dynamicType()` call.&nbsp;</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><span style="color: rgb(51, 51, 51); font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; text-align: justify;" class="">We have one keyword left in the language,&nbsp;</span><tt class="literal docutils" style="color: rgb(51, 51, 51); font-size: 1em; text-align: justify; background-color: rgb(226, 226, 226);"><span class="pre">dynamicType</span></tt><span style="color: rgb(51, 51, 51); font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; text-align: justify;" class="">, which is camel cased. This proposal renames it to&nbsp;</span><tt class="literal docutils" style="color: rgb(51, 51, 51); font-size: 1em; text-align: justify; background-color: rgb(226, 226, 226);"><span class="pre">Self</span></tt><span style="color: rgb(51, 51, 51); font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; text-align: justify;" class="">&nbsp;instead.</span></div></blockquote><font color="#333333" face="DejaVu Sans, Arial, Helvetica, sans-serif" class=""><br class=""></font><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><span style="color: rgb(51, 51, 51); font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; text-align: justify;" class="">Why don’t we turn this into a standard library function? It’s not something you need so often that the member access is very valuable. Putting it in the standard library as&nbsp;</span><tt class="literal docutils" style="color: rgb(51, 51, 51); font-size: 1em; text-align: justify; background-color: rgb(226, 226, 226);"><span class="pre">dynamicType(_:)</span></tt><span style="color: rgb(51, 51, 51); font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; text-align: justify;" class="">&nbsp;does still allow for that function to be implemented using compiler magic.</span></blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div style="text-align: justify;" class=""><font color="#333333" face="DejaVu Sans, Arial, Helvetica, sans-serif" class=""><br class=""></font></div><span style="color: rgb(51, 51, 51); font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; text-align: justify;" class="">Another approach would be to introduce a new&nbsp;</span><tt class="literal docutils" style="color: rgb(51, 51, 51); font-size: 1em; text-align: justify; background-color: rgb(226, 226, 226);"><span class="pre">dynamictype</span></tt><span style="color: rgb(51, 51, 51); font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; text-align: justify;" class="">&nbsp;keyword that doesn’t need to be accessed as a member of&nbsp;</span><tt class="literal docutils" style="color: rgb(51, 51, 51); font-size: 1em; text-align: justify; background-color: rgb(226, 226, 226);"><span class="pre">self</span></tt><span style="color: rgb(51, 51, 51); font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; text-align: justify;" class="">, and keep&nbsp;</span><tt class="literal docutils" style="color: rgb(51, 51, 51); font-size: 1em; text-align: justify; background-color: rgb(226, 226, 226);"><span class="pre">Self</span></tt><span style="color: rgb(51, 51, 51); font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; text-align: justify;" class="">&nbsp;the way it is.&nbsp;&nbsp;</span><tt class="literal docutils" style="color: rgb(51, 51, 51); font-size: 1em; text-align: justify; background-color: rgb(226, 226, 226);"><span class="pre">Self</span></tt><span style="color: rgb(51, 51, 51); font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; text-align: justify;" class="">&nbsp;should work in structs as a type alias.</span></blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><span style="color: rgb(51, 51, 51); font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; text-align: justify;" class=""><br class=""></span></blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><span style="color: rgb(51, 51, 51); font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; text-align: justify;" class="">Another perspective is that&nbsp;</span><tt class="literal docutils" style="color: rgb(51, 51, 51); font-size: 1em; text-align: justify; background-color: rgb(226, 226, 226);"><span class="pre">.dynamicType</span></tt><span style="color: rgb(51, 51, 51); font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; text-align: justify;" class="">&nbsp;is just an implicitly synthesized property on all type.<br class=""></span><br class=""><span style="color: rgb(51, 51, 51); font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; text-align: justify;" class="">Subjectively, having&nbsp;</span><tt class="literal docutils" style="color: rgb(51, 51, 51); font-size: 1em; text-align: justify; background-color: rgb(226, 226, 226);"><span class="pre">dynamicType</span></tt><span style="color: rgb(51, 51, 51); font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; text-align: justify;" class="">&nbsp;as a member feels weird.</span></blockquote><div class=""><b class=""><br class=""></b></div><div class="">If retained as a keyword, I believe it should be lowercased to `dynamictype`. This leaves two remaining outliers (`willSet` and `didSet`). If it is re-introduced as a stdlib function, it should be `dynamicType()`.</div><div class=""><br class=""></div><div class=""><b class="">------</b></div><div class=""><b class=""><br class=""></b></div><div class=""><b class="">ORIGINAL DESIGN TEAM FEEDBACK</b></div><div class=""><div class="section" id="se-0068-expanding-swift-self-to-class-members-and-value-types" style="color: rgb(51, 51, 51); font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif;"><h3 class="" style="font-size: 1.1em; font-weight: normal; color: rgb(12, 55, 98); margin-top: 30px;">SE-0068: Expanding Swift Self to class members and value types<a class="headerlink" href="file:///Users/alexmartini/DevPubs%20Git%20Repositories/Swift%20Language%20Review/_build/html/LR_MeetingNotes/2016-04-20.html#se-0068-expanding-swift-self-to-class-members-and-value-types" title="Permalink to this headline" style="visibility: hidden; font-weight: bold; text-decoration: none; color: rgb(167, 206, 56); padding-left: 5px;"></a></h3><p class="" style="text-align: justify;"><a class="external reference" href="https://github.com/apple/swift-evolution/blob/master/proposals/0068-universal-self.md" style="font-weight: bold; text-decoration: none; color: rgb(137, 38, 1);">https://github.com/apple/swift-evolution/blob/master/proposals/0068-universal-self.md</a></p><p class="" style="text-align: justify;">We have one keyword left in the language,&nbsp;<tt class="literal docutils" style="background-color: rgb(226, 226, 226); font-size: 1em;"><span class="pre">dynamicType</span></tt>, which is camel cased. This proposal renames it to&nbsp;<tt class="literal docutils" style="background-color: rgb(226, 226, 226); font-size: 1em;"><span class="pre">Self</span></tt>&nbsp;instead.</p><p class="" style="text-align: justify;">In a static function today,&nbsp;<tt class="literal docutils" style="background-color: rgb(226, 226, 226); font-size: 1em;"><span class="pre">self.dynamicType</span></tt>&nbsp;will give you a metatype but the non-member&nbsp;<tt class="literal docutils" style="background-color: rgb(226, 226, 226); font-size: 1em;"><span class="pre">Self</span></tt>&nbsp;will not. The most useful reason to reference it is to call an initializer. It makes accessing the metatype weirder. It’s not&nbsp;<tt class="literal docutils" style="background-color: rgb(226, 226, 226); font-size: 1em;"><span class="pre">Self.Type</span></tt>; that’s a type — you have to spell it&nbsp;<tt class="literal docutils" style="background-color: rgb(226, 226, 226); font-size: 1em;"><span class="pre">Self.type</span></tt>.</p><p class="" style="text-align: justify;">Quiz time! What do each of the permutations mean?</p><div class="highlight-python"><div class="highlight" style="background-color: rgb(238, 255, 204);"><pre class="" style="overflow-x: auto; overflow-y: hidden; border: thin dotted rgb(12, 55, 98); margin-top: 0px; margin-bottom: 12px; padding: 0.8em; background-color: rgb(240, 240, 240);"><span class="n">Self</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="n">self</span>
<span class="bp" style="color: rgb(0, 112, 32);">self</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="n">Self</span>
<span class="n">Self</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="n">Self</span>
<span class="bp" style="color: rgb(0, 112, 32);">self</span><span class="o" style="color: rgb(102, 102, 102);">.</span><span class="n">self</span>
</pre></div></div><p class="" style="text-align: justify;">The number of capital letters gives you the level of meta-ness. This is very subtle, which is probably not a good thing.</p><p class="" style="text-align: justify;">Another approach would be to introduce a new&nbsp;<tt class="literal docutils" style="background-color: rgb(226, 226, 226); font-size: 1em;"><span class="pre">dynamictype</span></tt>&nbsp;keyword that doesn’t need to be accessed as a member of&nbsp;<tt class="literal docutils" style="background-color: rgb(226, 226, 226); font-size: 1em;"><span class="pre">self</span></tt>, and keep&nbsp;<tt class="literal docutils" style="background-color: rgb(226, 226, 226); font-size: 1em;"><span class="pre">Self</span></tt>&nbsp;the way it is.&nbsp;&nbsp;<tt class="literal docutils" style="background-color: rgb(226, 226, 226); font-size: 1em;"><span class="pre">Self</span></tt>&nbsp;should work in structs as a type alias.</p><p class="" style="text-align: justify;">Why don’t we turn this into a standard library function? It’s not something you need so often that the member access is very valuable. Putting it in the standard library as&nbsp;<tt class="literal docutils" style="background-color: rgb(226, 226, 226); font-size: 1em;"><span class="pre">dynamicType(_:)</span></tt>&nbsp;does still allow for that function to be implemented using compiler magic.</p><div class="highlight-python"><pre class="" style="overflow-x: auto; overflow-y: hidden; border: thin dotted rgb(12, 55, 98); margin-top: 0px; margin-bottom: 12px; padding: 0.8em; background-color: rgb(240, 240, 240);">func dynamicType&lt;T&gt;(_: T) -&gt; T.Type { }</pre></div><p class="" style="text-align: justify;">We have a proposal to remove&nbsp;<tt class="literal docutils" style="background-color: rgb(226, 226, 226); font-size: 1em;"><span class="pre">.self</span></tt>&nbsp;on types. One reason&nbsp;<tt class="literal docutils" style="background-color: rgb(226, 226, 226); font-size: 1em;"><span class="pre">.self</span></tt>&nbsp;exists is to avoid the mistake of writing&nbsp;<tt class="literal docutils" style="background-color: rgb(226, 226, 226); font-size: 1em;"><span class="pre">let</span>&nbsp;<span class="pre">x</span>&nbsp;<span class="pre">=</span>&nbsp;<span class="pre">Int</span></tt>&nbsp;— the compiler will give you a weird type error later on in code if the value of&nbsp;<tt class="literal docutils" style="background-color: rgb(226, 226, 226); font-size: 1em;"><span class="pre">x</span></tt>&nbsp;is what we today call&nbsp;<tt class="literal docutils" style="background-color: rgb(226, 226, 226); font-size: 1em;"><span class="pre">Int.self</span></tt>&nbsp;but you meant to call the&nbsp;<tt class="literal docutils" style="background-color: rgb(226, 226, 226); font-size: 1em;"><span class="pre">Int()</span></tt>&nbsp;initializer. Creating a metatype is not a common operation, so doing it explicitly is a good thing.</p><p class="" style="text-align: justify;">It’s weird that you can use the metatype directly to construct something or to do member access, but you can’t access it as a bare value.</p><p class="" style="text-align: justify;">Coming back to this proposal, if we removed&nbsp;<tt class="literal docutils" style="background-color: rgb(226, 226, 226); font-size: 1em;"><span class="pre">.self</span></tt>&nbsp;why would we want to add&nbsp;<tt class="literal docutils" style="background-color: rgb(226, 226, 226); font-size: 1em;"><span class="pre">.Self</span></tt>?</p><p class="" style="text-align: justify;">If you have a variable whose value is a metatype, you also keep its name in lower case. So&nbsp;<tt class="literal docutils" style="background-color: rgb(226, 226, 226); font-size: 1em;"><span class="pre">Self</span></tt>&nbsp;makes a little less sense from that aspect too.</p><p class="" style="text-align: justify;">Another perspective is that&nbsp;<tt class="literal docutils" style="background-color: rgb(226, 226, 226); font-size: 1em;"><span class="pre">.dynamicType</span></tt>&nbsp;is just an implicitly synthesized property on all type.</p><p class="" style="text-align: justify;">We do have other keywords that follow the dot on types,&nbsp;<tt class="literal docutils" style="background-color: rgb(226, 226, 226); font-size: 1em;"><span class="pre">Int.Type</span></tt>&nbsp;and&nbsp;<tt class="literal docutils" style="background-color: rgb(226, 226, 226); font-size: 1em;"><span class="pre">Fooable.Protocol</span></tt>, so this isn’t the only thing. Those things are magic nested types.</p><p class="" style="text-align: justify;">Subjectively, having&nbsp;<tt class="literal docutils" style="background-color: rgb(226, 226, 226); font-size: 1em;"><span class="pre">dynamicType</span></tt>&nbsp;as a member feels weird.</p><p class="" style="text-align: justify;">If&nbsp;<tt class="literal docutils" style="background-color: rgb(226, 226, 226); font-size: 1em;"><span class="pre">.self</span></tt>&nbsp;goes away, the four-self example above is simplified, and&nbsp;<tt class="literal docutils" style="background-color: rgb(226, 226, 226); font-size: 1em;"><span class="pre">.Self</span></tt>&nbsp;doesn’t make sense anymore. There’s also the difference that&nbsp;<tt class="literal docutils" style="background-color: rgb(226, 226, 226); font-size: 1em;"><span class="pre">.Self</span></tt>&nbsp;would be a runtime thing.</p><div class=""><br class=""></div></div><div class="section" id="what-to-do-about-optional-requirements" style="color: rgb(51, 51, 51); font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif;"></div></div></body></html>