[swift-evolution] [Proposal] Disallow redundant `Any<...>` constructs
matthew at anandabits.com
Fri May 20 22:58:34 CDT 2016
Sent from my iPad
On May 20, 2016, at 10:47 PM, Brent Royal-Gordon <brent at architechies.com> wrote:
>> One more point around this comment. While `any<MyProtocol>` is a type `any` is not a type. `any` is a kind of type. We have classes, structs, enums, and existentials. We don’t capitalize `struct`, `class`, or `enum`. Why should we capitalize `any` just because it is often going to be declared ad-hoc (and again, I think it is worthwhile to give existential types a name in many cases, just as we give other types a name — preferring structs to tuples, for example). Making `any` lowercase emphasizes the fact that it is a kind of type rather than a type.
> The current `Any`, and the proposed `any<>` (and `any`, which I'm presuming is equivalent), *are* types. They are not categories of types like `class` or `struct` or `enum`;
Existentials most definitely are a distinct kind / category of type, with a distinct implementation and a distinct runtime representation.
> you can declare variables as them, you can cast to them, you can check if values match them. You probably ought to be able to take an `Any<Foo, Bar>.Type` and call a `Foo` or `Bar` initializer on it to get an `Any<Foo, Bar>` (although I don't know if Swift supports that right now). In short, you can do all the things with them that one would expect to do with a type. Because they are types.
> So if you're saying that `any<>`/`Any<>` is not a type, I think you're quite wrong. If you're saying that `any<>`/`Any<>` is a type but `any`/`Any` is not, then we disagree on my position that these should be equivalent.
I am saying the latter. I prefer the lowercase keyword and uppercase 'typealias Any = any<>'
> Brent Royal-Gordon
More information about the swift-evolution