Sent from my iPad

> On May 28, 2016, at 12:50 PM, Thorsten Seitz <[email protected]> wrote:
> 
> 
>> Am 28.05.2016 um 19:35 schrieb Austin Zheng <[email protected]>:
>> 
>> Sorry, 'with' in the second example should be 'where'. My personal 
>> preference is to keep 'where' for both uses, since they are serving the same 
>> purpose.
>> 
>>>> On May 28, 2016, at 10:33 AM, Austin Zheng <[email protected]> wrote:
>>>> 
>>>> -Thorsten
>>> 
>>> We could make parentheses optional in the general case, and just have them 
>>> mandatory in the following situations:
>>> 
>>> - You want to nest an existential literal inside another existential 
>>> literal:
>>> let a : Protocol1, (Protocol2 where .Blah == Int), Protocol3 = foo()
> 
> When using `&` instead of `,` this would not be required (not even for 
> readability IMO).
> 
> 
>>> 
>>> - You want to return an existential with more than one term and/or a where 
>>> clause from a function that has a generic where clause
>>> func foo<P, Q>(p: P, q: Q) -> (Collection with .Element == P) where P : 
>>> Equatable { … }
> 
> For return types (if staying with `where` instead of `with`) the parentheses 
> would be required iff only one `where` is present.
> They would not be strictly required if two `where` clauses would be present, 
> but I would be ok if they would be mandatory in that case.
> 
> 
>>> 
>>> - You want to use an existential as a function argument, and that 
>>> existential has more than one term and/or a where clause
>>> func foo(x: Protocol1, y: (Protocol2 where .Blah == Int), z: Protocol3) { … 
>>> }
> 
> I wouldn’t require them here. For one the function does not look too bad 
> without the parentheses:
> 
> func foo(x: Protocol1, y: Protocol2 where .Blah == Int, z: Protocol3) { … }
> 
> But even more important: when formatting this function across multiple lines 
> (which I might rather do to improve readability instead of adding 
> parentheses) I would definitely *not* want to have to use parentheses:
> 
> func foo(
>       x: Protocol1, 
>       y: Protocol2 where .Blah == Int, 
>       z: Protocol3) 
> { … }
> 

I agree with everything Thorsten said.  Parents are used to resolve ambiguity.  
If we need to go a bit further than is strictly necessary for that purpose in 
order to make return types feel a bit more consistent that is ok.  I don't mind 
requiring them for a return type with a where clause, but that's as far as I'd 
go.

> 
> -Thorsten
> 
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to