[swift-evolution] Making `.self` After `Type` Optional

Dave Abrahams dabrahams at apple.com
Thu Mar 10 13:46:54 CST 2016


> On Mar 10, 2016, at 9:19 AM, Joe Groff <jgroff at apple.com> wrote:
> 
> - As the parameter to an operator:
> 
> ++Foo<T> // prefix
> Foo<T>++ // postfix
> Foo<T>+Bar<U> // infix
> Foo<T> + Bar<U>
How is this case different.
> let foo = Bar<U>

Is assignment an operator?
> 
> This one's a bit interesting since `>+` or `>++` could be operators themselves. Applying operators to types might not be a compelling enough reason to block the other changes, though.

I’d be totally willing to say that if you want to apply an operator (other than assignment) to a type you need to put it in parentheses.

++(Foo<T>) // prefix
(Foo<T>)++ // postfix
(Foo<T>)+(Bar<U>) // infix
(Foo<T>) + (Bar<U>)
let foo = Bar<U>

> 
> For (B), as I mentioned before, it makes the choice between [T] becoming 'Array<T>' or becoming an array containing 'T' a bit of an overload resolution problem. In most cases we can probably favor the type sugar, either by argument type context or by syntactically recognizing `T` as a static type reference and favoring the type sugar interpretation over the array literal implementation. Doug or Joe Pamer probably have opinions here.
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160310/fa572209/attachment.html>


More information about the swift-evolution mailing list