<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=""><div class="">Ambiguous in two cases:</div><div class="">- when passing an argument (is this implied self, or implied type? — clashes with shortcut for enums etc)</div><div class="">- starting the line with a dot now allows you to continue the method chain from the previous line.</div><div class=""><br class=""></div><div class=""><br class=""></div><br class=""><div class="">
<div class="">— Radek</div>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On 19 Dec 2015, at 01:50, Paul Ossenbruggen 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=""><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="">This may have been covered in the past but is there any reason why we can’t require use “.property”? It would work similar to the way you can use “.property” in enums. This would be terse, consistent with enum, and would help the call site be more explicit. This would be the same as self.property. I would not mind having that in my call sites. </span><div class="" 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;"><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 17, 2015, at 11:53 AM, Daniel Hooper 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 dir="ltr" class="" 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;">I have mixed feelings about this proposal: I see some value in the problems it is trying to address, though there are other ways to solve them.<div class=""><br class=""></div><div class="">The two problems it tried to address that I consider legitimate:<div class="">1. bullet proofing against bugs. </div><div class="">The example in the motivation section is a good one. I can imagine this happening, though I haven't ever personally experienced it, so how often does it really happen? Is it often enough to warrant this requirement? The root cause of that bug is that the instance variable was shadowed by a local one. Requiring self is one way to ensure local variables don't shadow instance variables, but the compiler could also just disallow shadowing instance variables. Details aside, the take away here is that there are other solutions to this problem.<br class=""></div><div class=""><br class=""></div><div class="">2. Clarity at the call site.</div><div class="">Syntax highlighting solves this with two caveats: color blindness and non-colored code, such as diffs in the terminal. Color blindness can be helped by changing the coloring rules to make it easier to differentiate ivars. I don't have an answer for situations with no syntax coloring, though in my own workflow that isn't really an issue. For teams that it is, they could require use of self, or ivar prefixes ("var _ivar")</div><div class=""><br class=""></div><div class="">So while both problems could be legitimate, there are other ways of addressing them that don't require the verbosity of "self."</div><div class=""><br class=""></div><div class="">Thought experiment:</div><div class="">"self." has a lot of baggage from obj-c, python, etc, so as an experiment let's extended this proposal to it's logical conclusion and see how we feel about it: Global variables and functions have this same shadowing situation that ivars and instance methods do: an identifier without "self." could be referencing a local or global variable. Here is the same example from the proposal, but with a global variable instead of the ivar:</div><div class=""><br class=""></div><div class=""><pre class="" style="overflow: auto; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; margin-top: 0px; margin-bottom: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.45; padding: 16px; background-color: rgb(247, 247, 247); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: normal; word-break: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; word-spacing: 0px;"><font color="#a71d5d" class="">let </font><span class="" style="color: rgb(51, 51, 51);">greeting = "Hi There"</span></pre><pre class="" style="overflow: auto; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; margin-top: 0px; margin-bottom: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1.45; padding: 16px; background-color: rgb(247, 247, 247); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: normal; word-break: normal; color: rgb(51, 51, 51); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; word-spacing: 0px;"><span class="pl-k" style="color: rgb(167, 29, 93);">class</span> MyViewController <span class="pl-k" style="color: rgb(167, 29, 93);">:</span> UIViewController {
<span class="pl-k" style="color: rgb(167, 29, 93);">@IBOutlet</span> <span class="pl-k" style="color: rgb(167, 29, 93);">var</span> button: UIButton<span class="pl-k" style="color: rgb(167, 29, 93);">!</span>
<span class="pl-k" style="color: rgb(167, 29, 93);">func</span> <span class="pl-en" style="color: rgb(121, 93, 163);">updateButton</span>() {
<span class="pl-c" style="color: rgb(150, 152, 150);">// var greeting = "Good morning"</span>
button<span class="pl-k" style="color: rgb(167, 29, 93);">.</span>setTitle(greeting, forState: <span class="pl-k" style="color: rgb(167, 29, 93);">.</span>Normal) <span class="pl-c" style="color: rgb(150, 152, 150);">// forgot to comment this line but the compiler does not complain and greeting is now referencing global greeting by mistake</span>
}
}</pre></div><div class=""><br class=""></div><div class="">By this proposal's logic we should create a "global." prefix and require it to access global variables and functions. Only local variables and functions could be accessed without a prefix. If we approve this proposal then maybe this is a great idea, or maybe this example shows some flaw in the proposal. Either way, hopefully it can help us see the proposal in a new light.</div><div class=""><br class=""></div><div class="">Daniel</div><div class=""><br class=""></div><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Thu, Dec 17, 2015 at 1:03 PM Michael Brown via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank" 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 class="" style="word-wrap: break-word;"><div class=""><blockquote type="cite" class=""><div class="">On 17 Dec 2015, at 17:54, Dan Loewenherz <<a href="mailto:dan@lionheartsw.com" target="_blank" class="">dan@lionheartsw.com</a>> wrote:</div><br class=""></blockquote></div></div><div class="" style="word-wrap: break-word;"><div class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class="" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">On Thu, Dec 17, 2015 at 11:28 AM, Michael Brown via swift-evolution<span class=""> </span><span dir="ltr" class=""><<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>></span><span class=""> </span>wrote:<br class=""></div></div></blockquote></div></div><div class="" style="word-wrap: break-word;"><div class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class="" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><div class="gmail_extra"><div class="gmail_quote"><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;">On Tue, Dec 15, 2015 at 21:03 Sune Foldager via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>> wrote:<br class=""><br class=""></blockquote></div></div></div></div></blockquote></div></div><div class="" style="word-wrap: break-word;"><div class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class="" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><div class="gmail_extra"><div class="gmail_quote"><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;">> “self.” everywhere means you can see what’s an instance member and what’s a local variable. That’s generally a good thing. But it also means a lot of filler text in your code, which makes reading and writing slower. That’s not so good. It’s a balance, and in this case my experience from C# (and, as mentioned, Python) is that I much prefer C#’s non-mandatory use of “this”/“self".<br class="">><br class="">> I see that this proposal is going to be reviewed as SE-0009, and I am a bit concerned that not all arguments are being considered because of the contents of the proposal text: The only counter argument mentioned in the proposal has to do with capturing semantics in closures. This is fine, but why isn’t the counter argument of verbosity being mentioned? This has been brought up on the list as well.<br class="">><br class=""><br class=""></blockquote></div></div></div></div></blockquote></div></div><div class="" style="word-wrap: break-word;"><div class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class="" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><div class="gmail_extra"><div class="gmail_quote"><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;">I couldn't agree more on all points. I strongly object to this proposal. Requiring self makes code unnecessarily verbose and is one of the things I least liked about Objective-C compared to other languages (e.g. C#, Python, Java) where the use of self/this is optional. It is only only actually necessary when resolving ambiguity with local variables, in the few situations where such ambiguity exists (initialisers mostly).<br class=""></blockquote></div></div></div></div></blockquote></div></div><div class="" style="word-wrap: break-word;"><div class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class="" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><div class="gmail_extra"><div class="gmail_quote"><div class=""><br class=""></div><div class="">Correction: self is not optional in Python.</div></div></div></div></div></blockquote></div></div><div class="" style="word-wrap: break-word;"><div class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class="" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><div class="gmail_extra"><div class="gmail_quote"></div></div></div></div></blockquote><div class=""><br class=""></div><div class="">Yes. I realized my mistake soon after I hit send. Apologies.</div><br class=""></div><div class="">Michael.</div><br class=""><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=AdkfTiApI80cNEyortTzHX3rEsyQr33mtIPuQmFT8gLTcAoUQjOGfGAk0OSdDkRVBB0DXOF2vWHcRkGr66bzGPrMG-2BsGGo5rdKW502hHgW0m9QRxdNsdir2TNyIn1VuapsNg4f2Z0Pu10s2XoqPQkN5od6gn6S8x2fyntmXLHqyZCfVR51N2nm7IgqpSsfBcp7ro6a7Wyc2sbRlUsaWZI6BnDwa7RdDQT1JNaOMw1RM-3D" alt="" width="1" height="1" border="0" class="" style="min-height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;"></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></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=emrIhnP1hIf76Foxxv4NNJQX-2FWhcznESwKBSwD1MEwzuf8AE1jV2q2NxmwEPSTxNABzBUZLZ9BC8p7JVjUANGYvd0idaKu4ZM-2F4rBaypud-2FnaNZDdIezouFK5-2FJ3764i-2BC0f1qpFQNMoJvvbkYPw9fH-2FUuyktVskPhBMYxy69oG7T0ipiOnMvwzJZApwrjH4EQ8hQUH36YxAfoDEJFBHPw-3D-3D" alt="" width="1" height="1" border="0" class="" 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;"><span class="" 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;"><span class="Apple-converted-space"> </span>_______________________________________________</span><br class="" 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;"><span class="" 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;">swift-evolution mailing list</span><br class="" 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;"><a href="mailto:swift-evolution@swift.org" class="" 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;">swift-evolution@swift.org</a><br class="" 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;"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="" 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;">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br class=""></div></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=4hhvaxvZNsLrnZM9llg93kxoqfFYC8lhv8HAehOIDqKWdDVIO4fssqCFLZWk91uJ3Qkw0MaCWeXaVvU9hc6JYnJ30BgSJOK96Ybs8oiWKsTF4D3RhTaODBhOjGgu0NSoaB4JWZtGC4oF2hlI0E9XCQDr4EAlFlybregC-2BN68DYTkP-2BFJ35WgwTRtpT02QcBSw-2BoMgLer8FS8yxclMk681-2F6XgSB8pd450-2BL4ist-2BGjw-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><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>