[swift-evolution] Move where clause to end of declaration
david at hartbit.com
Mon May 2 03:18:08 CDT 2016
Yep, I made a pull request already, but I still need to fix the thread link once games becomes available again. I’ll add an example about the current proposal allowing you to move the inheritance constraints out :) It’s good to have the choice.
> On 02 May 2016, at 10:11, Pyry Jahkola <pyry.jahkola at iki.fi> wrote:
> Thank you for the effort David, this is great!
> Considering this example:
>> On 02 May 2016, David Hart <david at hartbit.com <mailto: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...
More information about the swift-evolution