[swift-evolution] Making `.self` After `Type` Optional
Dave Abrahams
dabrahams at apple.com
Wed Mar 9 16:28:05 CST 2016
on Wed Mar 09 2016, Brent Royal-Gordon <swift-evolution at swift.org> wrote:
>> I would like to propose making `.self` After a Type optional when referencing Types in expressions.
>
>> This has been confirmed as a bug, and the report can be seen here <https://bugs.swift.org/browse/SR-899>.
>>
>> After a Twitter conversation with Joe Groff on the Swift team
>> (https://twitter.com/jckarter/status/707287663586324481) it is
>> determined that this requirement is due to difficulty disambiguating
>> generics `Foo<T>` vs infix less-than operations `Foo < T`.
>
> My understanding from previous Twitter discussions is that the primary
> reason for this feature is to keep you from writing `Foo` where you
> meant `Foo()`. That is, it's a deliberate design, meant to keep you
> from making mistakes. I suspect that you will have to overcome *that*
> impulse, not just any narrow parsing issue.
That is correct. Before 1.0, Swift used to work without ".self"; we
started requiring ".self" because one of the Swift designers
with experience in other languages that didn't require ".self" said that
it was a persistent source of confusion for users.
Personally, I've always disliked what ".self" did to my source code, but I
have no basis on which to argue with that other designer's experience.
--
-Dave
More information about the swift-evolution
mailing list