<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>I also wholeheartedly agree. I've always been a bit confused by that keyword in that context.<br><br>Sent from my iPhone</div><div><br>On 15 Dec 2015, at 17:42, Brandon Knope via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div>Doh! staticType is the obvious choice!</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">I agree that adding more keywords can be bad, but in this case I think the clarity outweighs any downside:</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">SomeType.staticType</div><div id="AppleMailSignature">SomeType.self </div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">To me (and I'm sure many others) one is vastly more obvious and easier to understand. </div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">I still don't really understand what SomeType.self is trying to convey upon first glance</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">Brandon </div><div id="AppleMailSignature"><br>Sent from my iPad</div><div><br>On Dec 15, 2015, at 11:34 AM, Dennis Lysenko <<a href="mailto:dennis.s.lysenko@gmail.com">dennis.s.lysenko@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">+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><br></div><div>Main detractor is that creating more keywords isn't necessarily a good thing.</div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Dec 15, 2015 at 11:19 AM Brandon Knope via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div><span></span></div><div><span></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><br></div><div>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">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><br></div><div>Example: <ol style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;line-height:1.6em;list-style:none"><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"><code style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;word-wrap:break-word"><font face="UICTFontTextStyleTallBody"><span style="background-color:rgba(255,255,255,0);border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline">let</span> <span style="background-color:rgba(255,255,255,0);border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline">metatype</span><span style="background-color:rgba(255,255,255,0)">: </span><span style="background-color:rgba(255,255,255,0);border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline">SomeClass</span><span style="background-color:rgba(255,255,255,0)">.</span><span style="background-color:rgba(255,255,255,0);border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline">Type</span><span style="background-color:rgba(255,255,255,0)"> = SomeClass.</span><span style="background-color:rgba(255,255,255,0);border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline">self</span></font></code></li></ol><div><br></div><div>Is there a reason why this isn't <span style="background-color:rgba(255,255,255,0)">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><br></div><div>I propose changing the postfix self to something more obvious like "type"</div><div><br></div><div>Going back to the example:</div><div><ol style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;line-height:1.6em;list-style:none"><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"><code style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;word-wrap:break-word"><font face="UICTFontTextStyleTallBody"><span style="background-color:rgba(255,255,255,0);border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline">let</span> <span style="background-color:rgba(255,255,255,0);border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline">metatype</span><span style="background-color:rgba(255,255,255,0)">: SomeClass.</span><span style="background-color:rgba(255,255,255,0);border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline">Type</span><span style="background-color:rgba(255,255,255,0)"> = SomeClass.type</span></font></code></li></ol><div><br></div></div><div>Several reasons why I think this is better:</div><div>1. Postfix self is not obvious as an option as you never see a postfix self anywhere else </div><div>2. "self" does not clearly explain that the type is being returned </div><div>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>4. Instances have a dynamicType method. For consistency, classes, structs, etc., should have a type method</div><div><br></div><div>Any other suggestions would be welcome. </div><div><br></div><div>Brandon </div><span></span><br><span>Sent from my iPad</span><br></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:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important">
</div>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div>
</div></blockquote>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=nE9rxSXA5G4kxsTVkgv43hXwizS3O2z60WweqomIrdg8GNpRArfP-2BD6aIByMhqVlawfGP5cwMxpOU8jai1HyCrPBWF4FpqqtiQBinT6QhDDpsURhwuU-2BYHtJAKCcsZdXAqK1EuGvcWr2JzUG6DY-2FczoyyqLD6dBGLrTE-2BRT2cNO9ltdo-2BK5-2BZjnb7-2FiW0oEYYJ9afNqHwklTKnw9bKIsEEEWejYW2jbmt4CJj3v9l0s-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;">
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></body></html>