<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 16, 2015, at 1:32 PM, Stephen Celis &lt;<a href="mailto:stephen.celis@gmail.com" class="">stephen.celis@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">On Wed, Dec 16, 2015 at 2:18 PM, Matthew Johnson <span dir="ltr" class="">&lt;<a href="mailto:matthew@anandabits.com" target="_blank" class="">matthew@anandabits.com</a>&gt;</span> wrote:<br class=""><div class="gmail_extra"><div class="gmail_quote"><br class=""><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 style="word-wrap:break-word" class=""><div class="">I believe the dot abbreviation only works for enum cases right now.</div></div></blockquote><div class=""><br class=""></div><div class="">Nope :)</div><div class="">&nbsp;</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 style="word-wrap:break-word" class=""><div class="">I suppose those can be viewed as static members in some sense but they really something different than that.&nbsp; If I am mistaken I would like to be corrected.</div></div></blockquote><div class=""><br class=""></div><div class="">I'll do my best!</div><div class=""><br class=""></div><div class="">It works as I was trying to describe earlier. Any static member that returns Self. Try the following in a playground/REPL:<br class=""></div><div class=""><br class=""></div><div class=""><div class="">&nbsp; &nbsp; struct Foo {</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; static var bar: Foo {</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return Foo()</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; }</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; static func baz() -&gt; Foo {</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return Foo()</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; }</div><div class="">&nbsp; &nbsp; }</div><div class="">&nbsp; &nbsp; let bar: Foo = .bar</div><div class="">&nbsp; &nbsp; let baz: Foo = .baz()</div></div><div class=""><br class=""></div><div class="">Here's a SwiftStub demonstrating the behavior:&nbsp;<a href="http://swiftstub.com/579553153" class="">http://swiftstub.com/579553153</a></div><div class=""><br class=""></div><div class="">Enum cases work with dot abbreviation _because_ they are static members that return Self. Enumerations aren't special-cased for dot abbreviation.</div><div class=""><br class=""></div></div></div></div></div></blockquote><div><br class=""></div><div>I stand corrected. &nbsp;This is pretty interesting. &nbsp;Is this covered in any documentation? &nbsp;I haven’t seen anything about it nor any code that uses this until now. &nbsp;It would be useful with factory methods. &nbsp;I appreciate your calling this to my attention!</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><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"><div style="word-wrap:break-word" class=""><div class=""><div class="">The shadowing is *current* behavior in the language.&nbsp; It is not something I propose.</div></div></div></blockquote><div class=""><br class=""></div><div class="">Is this true? Can you provide a full example that works in the playground and demonstrates this? The hypothetical you paste already has certain ambiguous issues (e.g. `var foo` and `func foo()` cannot compile together because of redefinition).</div></div></div></div></div></blockquote><div><br class=""></div><div>Here is an example. &nbsp;I tested it in an app rather than a playground (moving the print line into main).</div><div><br class=""></div>struct&nbsp;Foo {</div><div>&nbsp; &nbsp;&nbsp;//static var bar: Foo -&gt; String = { _ in return "var" }<br class="">&nbsp; &nbsp;&nbsp;static&nbsp;func&nbsp;bar(f:&nbsp;Foo) -&gt;&nbsp;String&nbsp;{&nbsp;return&nbsp;"func"&nbsp;}<br class="">}</div><div>// prints “func”, but will compile and print “bar” if you uncomment the var<br class="">print(Foo.bar(Foo()))&nbsp;</div><div><br class=""></div><div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">&nbsp;</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 style="word-wrap:break-word" class=""><div class=""><div class="">This would not refer to either.&nbsp; It cannot refer to Foo.bar because Foo has nothing to do with the array you are mapping over.</div></div></div></blockquote><div class=""><br class=""></div><div class=""><div class="">The example I give works in the playground. Try it! :)</div></div></div></div></div></div></blockquote><div><br class=""></div><div>You are right here as well. &nbsp;I didn’t read closely enough and didn’t notice the overload of map you added to Array.</div><div><br class=""></div><div>If you remove that overload your code will fail to compile. &nbsp;This is because the dot abbreviation is context sensitive. &nbsp;It only works when the type system knows the type the expression is expected to produce.</div><div><br class=""></div><div>Because of this context sensitivity no ambiguity would arise from the example you provided. &nbsp;As you note, the type of the static property or method must always be Self, which is never going to be a function type. &nbsp;This means that it is never going to have the same type as an unbound instance method (that its non-self arguments bound). &nbsp;</div><div><br class=""></div><div>Because of this the two shorthand notations will never be applicable in the same type context. &nbsp;I can see how the similarity could be confusing but it is not ambiguous. &nbsp;The potential confusion might even be enough to avoid introducing it into the language, but I’m not sure about that. &nbsp;</div><div><br class=""></div><div>I still think it’s an interesting idea.</div></div><br class=""><div class="">Matthew</div></body></html>