[swift-evolution] My personal beef with leading-dot syntax
clattner at apple.com
Fri Apr 8 01:20:07 CDT 2016
> On Apr 6, 2016, at 9:27 AM, Jordan Rose via swift-evolution <swift-evolution at swift.org> wrote:
>> On Apr 5, 2016, at 0:55 , Radosław Pietruszewski via swift-evolution <swift-evolution at swift.org> wrote:
>> As others noted:
>> * the ability to say .min, .max, .blackColor(), etc is extremely useful. Swift would be a lot worse off if only enum cases got their enum types inferred, and for any other static member of a type I would have type the fully qualified name
>> * the leading dot disambiguates the reference for the compiler **and for the reader**. I don’t have to guess if I’m not referencing something local, or explicitly disambiguate when needed. I just say, “.foo”, and it’s clear.
>> * I disagree that the rules of lookup are confusing. The feature is poorly documented in official guides, but it seems pretty straightforward to me. For any context implying T, .foo means a static member T.foo. Like you said, could be subjective ¯\_(ツ)_/¯
> I strongly agree with all of these points, especially the second.
+1 to all these points. Also, in Swift 3, “.blackColor()” becomes “.black()”.
More information about the swift-evolution