<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">".self" was chosen for a few reasons:</div><div class=""><br class=""></div><div class="">- The obvious choice was ".class", given precedent in Objective-C and Java, but not all types are classes.</div><div class="">- 'type' is a very common property name, so we have tried very hard to avoid taking it as a general keyword.</div><div class="">- 'type' also always implies going up a level. "obj.dynamicType" gives you back the type of 'obj', so wouldn't "SomeClass.type" give you back the <a href="http://sealiesoftware.com/blog/archive/2009/04/14/objc_explain_Classes_and_metaclasses.html" class="">metaclass</a>? (Alternately, "SomeType.staticType' not being the same as 'SomeType.dynamicType" seems weird.)</div><div class="">- 'self' is already a keyword.</div><div class="">- ".self" actually works in Objective-C as well.</div><div class="">- ".self" currently also applies to instances, doing exactly what you think it does. This is <i class="">nearly</i> useless. In theory you could use it to unwrap one level of optionality ("doubleOpt?.self") but that doesn't actually work today.</div><div class=""><br class=""></div><div class="">I read "SomeType.self" as "SomeType itself, rather than an instance of it (or associated type)".</div><div class=""><br class=""></div><div class="">(And before someone brings it up, we chose not to just allow "SomeType" on its own because "let x = SomeType" is a likely typo for "let x: SomeType".)</div><div class=""><br class=""></div><div class="">I think coming up with a clearer name is possible here, but there's plenty to consider. Still, certainly a reasonable thing to bring up.</div><div class=""><br class=""></div><div class="">Best,</div><div class="">Jordan</div><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On Dec 15, 2015, at 8:42 , Brandon Knope via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">Doh! staticType is the obvious choice!</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">I agree that adding more keywords can be bad, but in this case I think the clarity outweighs any downside:</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">SomeType.staticType</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">SomeType.self </div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">To me (and I'm sure many others) one is vastly more obvious and easier to understand. </div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">I still don't really understand what SomeType.self is trying to convey upon first glance</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">Brandon </div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class="">Sent from my iPad</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class="">On Dec 15, 2015, at 11:34 AM, Dennis Lysenko <<a href="mailto:dennis.s.lysenko@gmail.com" class="">dennis.s.lysenko@gmail.com</a>> wrote:<br class=""><br class=""></div><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class=""><div dir="ltr" class="">+1. Side effects can be eliminated through code migration if a suitable property name is chosen. Perhaps `staticType` to continue in the vein of `dynamicType`? <div class=""><br class=""></div><div class="">Main detractor is that creating more keywords isn't necessarily a good thing.</div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Tue, Dec 15, 2015 at 11:19 AM Brandon Knope via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div dir="auto" class=""><div class=""><span class=""></span></div><div class=""><span class=""></span>One area of swift that is really not clear to me is when you want to use the type of a class, struct, enum, etc as a value. </div><div class=""><br class=""></div><div class="">Metatyping is explained here: <a href="https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Types.html#//apple_ref/doc/uid/TP40014097-CH31-XID_1022" target="_blank" class="">https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Types.html#//apple_ref/doc/uid/TP40014097-CH31-XID_1022</a></div><div class=""><br class=""></div><div class="">Example: <ol style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; line-height: 1.6em; list-style: none;" class=""><li style="text-indent: 0px; border-width: 0px 0px 0px 18px; border-left-style: solid; border-left-color: transparent; margin: 0px; outline: 0px; padding: 0px 10px 0px 0px; vertical-align: baseline; list-style-type: none;" class=""><code style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; word-wrap: break-word;" class=""><font face="UICTFontTextStyleTallBody" class=""><span style="background-color: rgba(255, 255, 255, 0); border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;" class="">let</span><span class="Apple-converted-space"> </span><span style="background-color: rgba(255, 255, 255, 0); border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;" class="">metatype</span><span style="background-color: rgba(255, 255, 255, 0);" class="">:<span class="Apple-converted-space"> </span></span><span style="background-color: rgba(255, 255, 255, 0); border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;" class="">SomeClass</span><span style="background-color: rgba(255, 255, 255, 0);" class="">.</span><span style="background-color: rgba(255, 255, 255, 0); border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;" class="">Type</span><span style="background-color: rgba(255, 255, 255, 0);" class=""><span class="Apple-converted-space"> </span>= SomeClass.</span><span style="background-color: rgba(255, 255, 255, 0); border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;" class="">self</span></font></code></li></ol><div class=""><br class=""></div><div class="">Is there a reason why this isn't <span style="background-color: rgba(255, 255, 255, 0);" class="">SomeClass.</span>type? Everywhere in the document this is explained as returning the type yet it's using a postfix self to access the type. </div><div class=""><br class=""></div><div class="">I propose changing the postfix self to something more obvious like "type"</div><div class=""><br class=""></div><div class="">Going back to the example:</div><div class=""><ol style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; line-height: 1.6em; list-style: none;" class=""><li style="text-indent: 0px; border-width: 0px 0px 0px 18px; border-left-style: solid; border-left-color: transparent; margin: 0px; outline: 0px; padding: 0px 10px 0px 0px; vertical-align: baseline; list-style-type: none;" class=""><code style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; word-wrap: break-word;" class=""><font face="UICTFontTextStyleTallBody" class=""><span style="background-color: rgba(255, 255, 255, 0); border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;" class="">let</span><span class="Apple-converted-space"> </span><span style="background-color: rgba(255, 255, 255, 0); border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;" class="">metatype</span><span style="background-color: rgba(255, 255, 255, 0);" class="">: SomeClass.</span><span style="background-color: rgba(255, 255, 255, 0); border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;" class="">Type</span><span style="background-color: rgba(255, 255, 255, 0);" class=""><span class="Apple-converted-space"> </span>= SomeClass.type</span></font></code></li></ol><div class=""><br class=""></div></div><div class="">Several reasons why I think this is better:</div><div class="">1. Postfix self is not obvious as an option as you never see a postfix self anywhere else </div><div class="">2. "self" does not clearly explain that the type is being returned </div><div class="">3. ObjC programmers are familiar with accessing the class type by sending the "class" method to the class type. In this case it needs to work on structs and enums, so a "type" method would make more sense. </div><div class="">4. Instances have a dynamicType method. For consistency, classes, structs, etc., should have a type method</div><div class=""><br class=""></div><div class="">Any other suggestions would be welcome. </div><div class=""><br class=""></div><div class="">Brandon </div><span class=""></span><br class=""><span class="">Sent from my iPad</span><br class=""></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=8CZIdLciSFC-2BO5jF-2FiP8qN7dBFsgCUZ50wdTsolcRPcMHsgQz33SrTbIBqh0dxknVxlPrKM0qDNDweGmZL1cMon3PZ86xs9skTnDn9Mn1zx1MxqQrWOqohYw-2BZuIliB4PP8pQkkyelHQxAWhhF1ffVk7-2F-2FYeJOfDcoz-2BBqTCHovFaF7LhZjwOQBBfBVHeCCYOqT6MJXwWRJr17QyAt9KJtBNrY4R0LnkavP7Rf5ghMc-3D" alt="" width="1" height="1" border="0" style="min-height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;" class=""></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></blockquote></div></div></blockquote><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=ZEz4qHYnXhPr3bBPu-2FxP4tN3HfWKL-2FtJpqkQ0gkOVSBU0O-2Fi1NF8tA7GaalX8cmwIU7WEl2pbyDNPPOi-2BYh-2BLE4v-2FpiJY9lSBlsmwJfgoiSOtJiuVJ6kvmGDuq7RId15VtsMr6M4r9fwXYFRLiYqBXoRDm7yAmZjCP-2BZTnlu-2BTPGuSLzXOIW4uEK7ytZYkoJ4zXJ6YNaCCMXpwE72Vx4bCmYJR3ZL3mHSqdrL73w0-2BA-3D" alt="" width="1" height="1" border="0" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""><span class="Apple-converted-space"> </span></span><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">swift-evolution mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:swift-evolution@swift.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">swift-evolution@swift.org</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br class=""></body></html>