[swift-evolution] Move where clause to end of declaration

Pyry Jahkola pyry.jahkola at iki.fi
Mon May 2 03:11:34 CDT 2016


Thank you for the effort David, this is great!

Considering this example:

> On 02 May 2016, David Hart <david at hartbit.com> wrote:
> 
> For example, here is the same function declaration (…) after the change: 
> func anyCommonElements<T : SequenceType, U : SequenceType>(lhs: T, _ rhs: U) -> Bool where
>     T.Generator.Element: Equatable,
>     T.Generator.Element == U.Generator.Element
> {
>     ...
> }
I originally had the opinion that this should be further changed for consistency into the following form:

func anyCommonElements<T, U>(lhs: T, _ rhs: U) -> Bool where
    T : SequenceType,
    U : SequenceType,
    T.Generator.Element : Equatable,
    T.Generator.Element == U.Generator.Element
{
    ...
}
However, I do agree now that in the simple case highlighted below it makes no sense to use the where clause at all:

> It was also proposed to remove the simple inheritance constraints from the generic parameter list, but several arguments were brought up that it would complicate declarations of simple generics which only needed inheritance constraints.
> 
Of course, the proposal doesn't prevent anyone from moving all inheritance constraints into the where clause, so maybe we should point out that it's also possible to further simplify the first line of function declarations that way. It just remains a stylistic choice left for the developer to choose.

Anyway, +1! Did you make a pull request already?

— Pyry

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


More information about the swift-evolution mailing list