<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=""><blockquote type="cite" class="">On Dec 13, 2015, at 1:15 AM, Rob Napier via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""></blockquote><div><blockquote type="cite" class=""><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">I wanted to reopen this discussion that seems to have trailed off. Requesting the return of self was my very first ask of Swift if I remember correctly (<a href="https://devforums.apple.com/message/1013085" class="">https://devforums.apple.com/message/1013085</a>). Continued work in Swift has both strengthened and modified that ask. Here are several of the examples discussed before:<div class=""><br class=""></div><div class=""><div class=""><a href="https://gist.github.com/schwa/94b11dc0a7a331f46b25" class="">https://gist.github.com/schwa/94b11dc0a7a331f46b25</a></div><div class=""><a href="https://gist.github.com/rnapier/478465d1b15e95b98b42" class="">https://gist.github.com/rnapier/478465d1b15e95b98b42</a></div><div class=""><a href="https://gist.github.com/rnapier/4213dc64206b17df6935" class="">https://gist.github.com/rnapier/4213dc64206b17df6935</a></div><div class=""><a href="https://gist.github.com/dwineman/d6c56ec0c0e2fdb761db" class="">https://gist.github.com/dwineman/d6c56ec0c0e2fdb761db</a></div><div class=""><div class=""><br class=""></div><div class="">I get that it seems tedious to type (and read) "self." and I get that "self." is currently a hint that self might be captured (but doesn't actually mean that, since you can use self. without capturing, and sometimes have to, very often in init, so really it's basically meaningless for that use).</div><div class=""><br class=""></div><div class="">That's why I suggest using .x and .f() to mark implicit self. I realize that this may conflict with enum usage. If so, then use another marker. For instance :x or ^x or anything. But implicit self is confusing in a lot of code, can (and does) lead to shadowing bugs, and is very difficult to reason about in diffs or any other interface that isn't an IDE (especially code review).</div><div class=""><br class=""></div><div class="">Thoughts, David? I agree with your basic proposal; I just want to amend it.</div><div class=""><br class=""></div><div class="">-Rob</div></div></div><div class=""><br class=""></div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=kND2tqgLiolwf1-2Bhgg7fFiaPS455NT9j3CATwJCX70-2BubbVARJ3IGnkMJYAszlA9vt3fOFbYM8YSxfJwAumRFtj8aq93Oa7-2BaxeaZLbTHrfgEGzUH9BU3Z9pXtgB9mqn-2Fb3S2V7swan-2F3F-2BamaCVk-2F5uMRISw-2BXZ5zcplKoF6R-2Bz-2FGAVIkVXWqJ-2BzWDD-2BxUft-2Fm-2FzFSsLFxMgQXh1wOMRwyw5KPA-2BMFR6hJvqNrnJ08-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;" class="">
_______________________________________________<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 class="">Since opinions seem to be divided on this, how about adding an optional warning flag to the compiler, which would warn if one accessed an instance variable or method without self. in front? That way, each person could choose whether they wanted implicit ‘self.’ or not. I know that this warning would be helpful to me, as I’ve already run into some rather weird bugs due to the implicit self, and it would be one less thing to debug.</div><div class=""><br class=""></div><div class="">Charles</div><div class=""><br class=""></div></body></html>