<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="">But “self” _is_ a reserved word, and that’s the whole reason that this proposal is necessary in the first place. If “self” were just a normal identifier, then “if let self = self” would work just as well as “if let foo = foo” and there would be nothing to discuss.</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class=""><div class="">The docs also say "The backticks are not considered part of the identifier; `x` and x have the same meaning." Thus `self` and self should have the same meaning.</div></div></div></blockquote><div class=""><br class=""></div><div class="">Well, `flurtzle` and flurtzle would have the same meaning, but `self` is an identifier whereas as self is a keyword, so they mean different things. That is precisely what the backticks are for.</div><br class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class=""><div class="">Assigning to `self` is the same as assigning to self, which intentionally isn't allowed.</div></div></div></blockquote><br class=""></div><div class="">No, you’re creating a new identifier called “self” which shadows the old one.</div><div class=""><br class=""></div><div class="">Consider this:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 10.5px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #323e7d" class="">let</span> foo: <span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" class="">Int</span>? = <span style="font-variant-ligatures: no-common-ligatures; color: #323e7d" class="">7</span></div><div style="margin: 0px; font-size: 10.5px; line-height: normal; font-family: Menlo; min-height: 12px;" class=""><span style="font-size: 10.5px;" class=""> </span><span style="font-size: 10.5px; color: rgb(50, 62, 125);" class="">if</span><span style="font-size: 10.5px;" class=""> </span><span style="font-size: 10.5px; color: rgb(50, 62, 125);" class="">let</span><span style="font-size: 10.5px;" class=""> foo = </span><span style="font-size: 10.5px; color: rgb(88, 126, 168);" class="">foo</span><span style="font-size: 10.5px;" class=""> {</span></div><div style="margin: 0px; font-size: 10.5px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" class="">print</span>(foo + <span style="font-variant-ligatures: no-common-ligatures; color: #323e7d" class="">1</span>)</div><div style="margin: 0px; font-size: 10.5px; line-height: normal; font-family: Menlo;" class=""> }</div></div><div class=""><br class=""></div><div class="">There are two identifiers named foo, one optional, one not. Both are declared with “let”, so neither can be assigned to. But the code works. Why? Because “let foo = foo” doesn’t assign to the outer variable; it creates a new one. If self were not a keyword, then it would work the same as “foo” above.</div><div class=""><br class=""></div><div class="">Cheers,</div><div class=""><br class=""></div><div class="">Paul</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 6, 2016, at 2:56 PM, Jacob Bandes-Storch 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="">Not exactly; backticks are for making an identifier out of something that's not normally an identifier. Most other reserved words are used in control flow & other declarations. Rarely do they actually represent identifiers/values that you can work with.<div class=""><div class=""><br class=""></div><div class="">The docs also say "The backticks are not considered part of the identifier; `x` and x have the same meaning." Thus `self` and self should have the same meaning. Assigning to `self` is the same as assigning to self, which intentionally isn't allowed. Backticks shouldn't allow you to circumvent that.</div><div class="gmail_extra"><br clear="all" class=""><div class=""><div class=""><div dir="ltr" class=""><div class="">Jacob<br class=""></div></div></div></div>
<br class=""><div class="gmail_quote">On Wed, Jan 6, 2016 at 12:50 PM, Paul Cantrell <span dir="ltr" class=""><<a href="mailto:paul@innig.net" target="_blank" class="">paul@innig.net</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">Ummm … isn’t that _exactly_ what backticks are for? From the docs:</div><div class=""><br class=""></div><div class=""><span style="color:rgb(65,65,65);font-family:Helvetica,Arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)" class=""> To use a reserved word as an identifier, put a backtick (</span><code style="border:0px;font-size:0.85em;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(128,128,128);font-family:Menlo,monospace;word-wrap:break-word" class="">`</code><span style="color:rgb(65,65,65);font-family:Helvetica,Arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)" class="">) before and after it.</span></div><div class=""><br class=""></div><br class=""><div class=""><blockquote type="cite" class=""><div class=""><div class=""><div class="">On Jan 5, 2016, at 10:42 PM, Greg Parker via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>> wrote:</div><br class=""></div></div><div class=""><div style="word-wrap:break-word" class=""><div class=""><div class=""><div class="">I think it is a bug :-) That's not what backquotes are for. It ought to be either supported without the backquotes or banned regardless of backquotes. </div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jan 5, 2016, at 8:34 PM, Jacob Bandes-Storch <<a href="mailto:jtbandes@gmail.com" target="_blank" class="">jtbandes@gmail.com</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class="">Yes, it seems to use the strong shadowing variable. (The compiler doesn't complain about "self.foo", and "self?.foo" becomes invalid because self is no longer optional.)<div class=""><br class=""></div><div class="">If it weren't so useful, I'd call it a bug.<br class=""><div class="gmail_extra">
<br class=""><div class="gmail_quote">On Tue, Jan 5, 2016 at 8:34 PM, Greg Parker <span dir="ltr" class=""><<a href="mailto:gparker@apple.com" target="_blank" class="">gparker@apple.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">Does further use of self after that actually use a strong shadowing variable? Or does it go back to the weak reference it already had as if the shadow were not there?</div><span class=""><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="">On Jan 5, 2016, at 8:26 PM, Jacob Bandes-Storch via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class="">Wow! I didn't know that worked. It's a bit surprising, and perhaps not intended. I think the proposal is still valid.<div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Jan 5, 2016 at 8:21 PM, Christopher Rogers <span dir="ltr" class=""><<a href="mailto:christorogers@gmail.com" target="_blank" class="">christorogers@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">You can shadow self with a guard like you wrote it if use the keyword escaping backquotes like so:<br class=""><br class="">guard let `self` = self else { return }</blockquote></div></div></div></div></blockquote></div></span></div></blockquote></div></div></div></div></div></blockquote></div><br class="">
</div></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=zCg-2FSGF9Wk188a6c55kLyEbrj7YhaXxFEHM-2F-2B0YAlzVd6mytc-2Bot4Nm0jCNAgoJQ9HD-2FdukApss0YvDHJVDga5JqX24xJKIBtSZZPdEpFRoxNQNHIojDDiWTjpRnu1FoNIrWUaH-2FfgGg4R-2BxhI1xHLGfmei8pcxFhZjUQ3tfKNrJDTLFWYVsIcJw8NTo-2B3Ktg4QOrmww9PmlDmkGobNutJFnEnBs3pBkJ0W9j9TJWms-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" class="">
</div><span class="">
_______________________________________________<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" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></span></div></blockquote></div><br class=""></div></blockquote></div><br class=""></div></div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=zCg-2FSGF9Wk188a6c55kLyEbrj7YhaXxFEHM-2F-2B0YAlzWxEnWvfi7JA5i1QSLdy7u-2B64k93tOKY6Y5nQcjiA1EuLXXpvTcCsJDo7kgQqLaQoIoJWE-2FmFb1dY3gwwhyP-2Bp1Ac-2BrvViJjIYhbyvJKZ-2FMxjf8aRQEAc8-2BhzfzGxmvL9wzPF74Stdord0Fp-2Fw6sdp4lOh2lr7dDdpzY0lcf7iKJpQIGmAe0297EFIldfhtwYs-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=""></body></html>