<div dir="ltr">+1 </div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 24, 2016 at 11:45 AM, Radosław Pietruszewski <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>Ah, didn’t realize this.</div><div><br></div><div>+1 then.</div><br><div>
<div>— Radek</div>
</div><div><div class="h5">
<br><div><blockquote type="cite"><div>On 24 Feb 2016, at 17:31, Douglas Gregor <<a href="mailto:dgregor@apple.com" target="_blank">dgregor@apple.com</a>> wrote:</div><br><div><div style="word-wrap:break-word"><br><div><blockquote type="cite"><div>On Feb 24, 2016, at 12:36 AM, Radosław Pietruszewski <<a href="mailto:radexpl@gmail.com" target="_blank">radexpl@gmail.com</a>> wrote:</div><br><div><div style="word-wrap:break-word"><div>Seems like an easy win, so I’m leaning towards a +1.</div><div><br></div><div>OTOH, are there any other cases where Swift -> ObjC automatically changes names of things to optimize for ObjC? If we don’t do more of that (the '<font face="Helvetica Neue">"Add needless words" to Objective-C method names’ thread, or other quick wins like this one), it would be weird to make just this one exception, a single special case. I fear this would be more surprising than not changing anything at all.</font></div></div></div></blockquote><div><br></div>We do a bunch of this already. We join the first argument label to the base name to form the first selector piece, inserting “with” if there’s no preposition in between already, and for throwing methods we either add “error:” in the appropriate place or append “AndReturnError” to the first selector piece if there are no other parameters.</div><div><br></div><div><span style="white-space:pre-wrap">        </span>- Doug</div><div><br></div><div><br><blockquote type="cite"><div><div style="word-wrap:break-word"><div>
<div>— Radek</div>
</div>
<br><div><blockquote type="cite"><div>On 23 Feb 2016, at 22:00, Douglas Gregor via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br><div><div style="word-wrap:break-word">Hi all,<div><br></div><div>The Swift API guidelines state that Boolean properties should reflect assertions about the receiver, so in Swift one would expect:</div><div><br></div><div><span style="white-space:pre-wrap">        </span>class Foo {</div><div><span style="white-space:pre-wrap">        </span> var isEnabled: Bool // good</div><div><span style="white-space:pre-wrap">        </span>}</div><div><br></div><div>rather than</div><div><br></div><div><span style="white-space:pre-wrap">        </span>class Foo {</div><div><span style="white-space:pre-wrap">        </span> var enabled: Bool // not Swifty</div><div><span style="white-space:pre-wrap">        </span>}</div><div><br></div><div>When the property is @objc, e.g.,</div><div><br></div><div><span style="white-space:pre-wrap">        </span>class Foo : NSObject {</div><div><span style="white-space:pre-wrap">        </span> @objc var isEnabled: Bool</div><div><span style="white-space:pre-wrap">        </span>}</div><div><br></div><div>The resulting Objective-C property doesn’t follow the <a href="https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingIvarsAndTypes.html#//apple_ref/doc/uid/20001284-BAJGIIJE" target="_blank">Cocoa guidelines for Objective-C</a>:</div><div><br></div><div><span style="white-space:pre-wrap">        </span>@property (readwrite,nonatomic) BOOL isEnabled;</div><div><br></div><div>because those guidelines state that properties do not use the “is” prefix.</div><div><br></div><div>My proposal is to strip the “is” prefix from the Objective-C name, but leave it off the getter, e.g.,</div><div><br></div><div><span style="white-space:pre-wrap">        </span>@property (readwrite,nonatomic,getter=isEnabled) BOOL enabled;</div><div><br></div><div>The change would have no effect on the Swift name; it will only affect the Objective-C property name and setter name.</div><div><br></div><div>Thoughts?</div><div><br></div><div><span style="white-space:pre-wrap">        </span>- Doug</div><div><br></div></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" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div></blockquote></div><br></div></div></blockquote></div><br></div></div></blockquote></div><br></div></div></div><br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">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>
<br></blockquote></div><br></div>