<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 Apr 24, 2016, at 7:57 PM, Brent Royal-Gordon 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 class=""><blockquote type="cite" class=""><span class="Apple-tab-span" style="white-space:pre">        </span><a href="https://github.com/apple/swift-evolution/blob/master/proposals/0068-universal-self.md" class="">https://github.com/apple/swift-evolution/blob/master/proposals/0068-universal-self.md</a><br class=""></blockquote><br class="">I'm not totally clear what's being proposed here.<br class=""><br class="">Is this valid?<br class=""><br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>class Foo {<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>static func bar() { … }<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>func baz(other: Foo) {<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>Self.bar()<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>}<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>}<br class=""></div></div></blockquote><div><br class=""></div><div>This is valid. Foo.bar(). </div><br class=""><blockquote type="cite" class=""><br class="">Is this valid?<br class=""><br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>struct Foo {<span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>// note: not class<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>static func bar() { … }<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>func baz(other: Foo) {<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>Self.bar()<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>}<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>}<br class=""><br class=""></blockquote><div><br class=""></div>This is valid. Foo.bar()</div><div><br class=""><blockquote type="cite" class=""><div class=""><div class="">Is this valid?<br class=""><br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>class Foo {<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>static func bar() { … }<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>func baz(other: Foo) {<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>other.Self.bar()<span class="Apple-tab-span" style="white-space:pre">        </span>// note: not self<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>}<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>}<br class=""><br class=""></div></div></blockquote><div><br class=""></div><div><div>This is valid. Foo.bar(). All instances of the class share the static bar() member.</div><div class=""><br class=""></div></div><blockquote type="cite" class=""><div class=""><div class="">Is this valid?<br class=""><br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>struct Foo {<span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>// note: not class<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>static func bar() { … }<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>func baz(other: Foo) {<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>other.Self.bar()<span class="Apple-tab-span" style="white-space:pre">        </span>// note: not self<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>}<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>}<br class=""><br class=""></div></div></blockquote><div><br class=""></div><div>This is should be valid although it currently errors with `dynamicType` (<b style="font-family: Menlo; font-size: 11px;" class="">error: type 'Foo' has no member 'bar'</b>). </div><div><br class=""></div><div>You missed subclassing, although being static members, methods are final and cannot be overridden. But if class Boo : Foo calls Self.bar() and Foo implements the static member, it's called from the Boo instance and uses the Foo implementation.</div><div><div><br class=""></div></div><blockquote type="cite" class=""><div class=""><div class="">Can a class have a variable (inside a method) of type Self? A return value? A parameter? A property?<br class=""></div></div></blockquote><div><br class=""></div><div>I think it should, however that technically may need to be of type #Self (per the original draft) instead of Self and have it expanded to the defining type at compile time.</div><br class=""><blockquote type="cite" class=""><div class=""><div class="">Can a value type have a variable (inside a method) of type Self? A return value? A parameter? A property?<br class=""></div></div></blockquote><div><br class=""></div><div>Ditto.</div><div><br class=""></div><div>-- E</div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div class=""><br class="">-- <br class="">Brent Royal-Gordon<br class="">Architechies<br class=""><br 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></div></blockquote></div><br class=""></body></html>