<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">That would be a Cocoa-side change, since UIView, NSView, NSMenuItem, NSCell are all Cocoa-level objects. (I’m not aware of any other type that would be commonly passed as a ‘sender’ parameter and would have a tag.) That change wouldn’t go through Swift-Evolution.<div class=""><br class=""></div><div class="">So in theory, if Swift 5 decides to get rid of the AnyObject dispatch, the Cocoa teams at Apple could work around that by introducing “@objc protocol IntegerTagged”, and introducing a migrator pass to look for '(sender as AnyObject).tag’ and rewrite it as `(sender as! IntegerTagged)?.tag.</div><div class=""><br class=""></div><div class="">If the ‘tag’ property is the only reason to keep AnyObject dispatch, I don’t think it’s worth its weight in the language.</div><div class=""><br class=""></div><div class="">-BJ<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Oct 25, 2017, at 8:28 AM, Charles Srstka 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=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">I guess, but doesn’t it seem far more elegant to have a protocol for tag-containing objects? This is a feature that’s pretty heavily used…<div class=""><br class=""></div><div class="">Charles<br class=""><div class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Oct 24, 2017, at 6:06 PM, Slava Pestov &lt;<a href="mailto:spestov@apple.com" class="">spestov@apple.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">You can implement an @objc protocol with an optional requirement, and make NSObject conform to it.<div class=""><br class=""></div><div class="">Slava<br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Oct 24, 2017, at 4:05 PM, Charles Srstka &lt;<a href="mailto:cocoadev@charlessoft.com" class="">cocoadev@charlessoft.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><blockquote type="cite" class="">On Oct 24, 2017, at 5:02 PM, Slava Pestov via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""></blockquote><div class=""><blockquote type="cite" class=""><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Thoughts? Does anyone actually rely on this feature, instead of just stumbling on it by accident once in a while?</span></div></blockquote></div><br class=""><div class="">The main thing I can think of off the top of my head is getting the tag from the sender in an IBAction:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">@IBAction</span> <span style="color: #ba2da2" class="">private</span> <span style="color: #ba2da2" class="">func</span> someAction(<span style="color: #ba2da2" class="">_</span> sender: <span style="color: #ba2da2" class="">Any</span>?) {</div></div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255);" class=""><div style="font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal;" class="">&nbsp; &nbsp;&nbsp;<span style="color: #ba2da2" class="">guard</span> <span style="color: #ba2da2" class="">let</span> tag = (sender <span style="color: #ba2da2" class="">as</span> <span style="color: #703daa" class="">AnyObject</span>?)?.tag <span style="color: #ba2da2" class="">as</span> <span style="color: #703daa" class="">Int</span>?&nbsp;<span style="color: #ba2da2" class="">else</span> { <span style="color: #ba2da2" class="">return</span> }</div><div style="font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal;" class=""><br class=""></div><div style="font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal;" class="">&nbsp; &nbsp; ...</div><div style="font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal;" class="">}</div><div style="font-family: Menlo; font-size: 14px; margin: 0px; font-stretch: normal; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">Unfortunately given how many unrelated Cocoa objects there are that implement -tag, it’s not really practical to implement this without the AnyObject dispatch. If a TagContaining protocol could be introduced and all the objects that implement -tag could be made to conform to it, then that would work around the problem (I believe I pitched this at some point long ago, but without catching any interest).</div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">Charles</div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><br class=""></div></div></div></div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div></div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></body></html>