[swift-evolution] My personal beef with leading-dot syntax

Brent Royal-Gordon brent at architechies.com
Mon Apr 4 22:04:39 CDT 2016


> Because semantically they seem more like types unto themselves

But they aren't types.

* You can't declare a variable/property/parameter of a particular case.
* You can't constrain a generic type parameter to a case.
* You can't cast to a case with `as` and friends or test for a case with `is`.
* You can't conform different cases to different protocols.
* You can't give different cases different members. (The associated value tuple is not a member; you can only access it with pattern matching.)

There is nothing subtle or ambiguous about this. Swift does not even blur the line anywhere, except in the switch statement (which is full of ad-hoc magic) and in the now-corrected capitalization convention. Cases simply *are not* types. They are different values which may be stored in the same type, just as `Int(1)` and `Int(2)` are not different types.

-- 
Brent Royal-Gordon
Architechies



More information about the swift-evolution mailing list