<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 15, 2015, at 2:39 PM, James Campbell &lt;<a href="mailto:james@supmenow.com" class="">james@supmenow.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">I think this should be extended to functions as well. How would you know the difference between a global function and a class function ?</div></div></blockquote><div><br class=""></div>We could take this to its logical extreme and require explicit capture lists for all closures, and some kind of prefix (outer.) on captured variable accesses inside closure bodies. :-)</div><div><br class=""></div><div>However, nobody would seriously propose this these days, because prevailing wisdom is that functions should be short and easy to read at a glance, especially if they involved nested functions, making it clear what values are captured where and so on.</div><div><br class=""></div><div>Why don't we push the same philosophy for classes also?</div><div><br class=""></div><div>I'm not just convinced that syntactic disambiguation of scope lookup is desirable...</div><div><br class=""></div><div>Slava</div><div><br class=""></div><div><blockquote type="cite" class=""><div class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Dec 15, 2015 at 10:28 PM, Slava Pestov via swift-evolution <span dir="ltr" class="">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br class="">
<br class="">
I don't see anyone lay out how this proposal can interact with nested types and such. There's a fair amount of complexity in Swift with what you can do by nesting things inside of each other, so the simple conceptual model of "locals are unqualified, instance variables have a self. prefix" doesn't seem to generalize.<br class="">
<br class="">
Will I need to qualify associated types with the protocol or type name to refer to them? What about generic type parameters, they're sort of like "instance variables" too.<br class="">
<br class="">
What about class methods that want to call each other? Do they need the explicit 'self', or an explicit class name prefix? The latter changes semantics if the class method is overridden in a subclass.<br class="">
<br class="">
If we ever add the ability for an inner type to capture stored properties from the outer type, how do you reference properties of the outer type? I guess the problem has to be solved anyway to refer to an outer "self" explicitly, but qualifying everything with OuterType.self.foo kind of defeats the purpose of inner types altogether.<br class="">
<br class="">
I'm not sure I buy the readability arguments in favor of this approach. It seems the languages where explicit 'self' was adopted did it mostly by accident, or because of implementation concerns. In Python for instance, there's no way for assignment to modify a binding in an outer scope, so 'foo = bar' always sets a local named 'foo', IIRC. So explicit self is needed there. Greg Parker explains earlier in this thread by explicit self was chosen for Objective-C, and it wasn't readability.<br class="">
<br class="">
Slava<br class="">
<div class="HOEnZb"><div class="h5">_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" 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="">
</div></div></blockquote></div><br class=""><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div class="gmail_signature"><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class=""><span style="font-size:16px;line-height:19.2px" class=""></span><span style="font-size:12.8px" class="">&nbsp;Wizard</span><br class=""></div><div class=""><a href="mailto:james@supmenow.com" target="_blank" class="">james@supmenow.com</a></div><div class="">+44 7523 279 698</div></div></div></div></div></div>
</div>
</div></blockquote></div><br class=""></body></html>