[swift-evolution] [Review] SE-0081: Move where clause to end of declaration

L. Mihalkovic laurent.mihalkovic at gmail.com
Mon May 16 02:10:12 CDT 2016



On May 16, 2016, at 12:45 AM, Brent Royal-Gordon via swift-evolution <swift-evolution at swift.org> wrote:

>> Being able to let the developer decide how to place relevant type information with the freedom of being able to keep some/all/none type information local and some/none/all extra information moved to the end of the declaration.
> 
> To be clear, I do think it makes sense to move *all* `where` clauses to the end of the parameter list, not allow them both within the angle brackets and at the end of the definition. And I'm not convinced it makes sense to support moving all conformance information to the `where` clause, either. A generic parameter list like `<T, U>` is vacuous; when you're dealing with something like this:
> 
>    public func transcode
>        <Input: IteratorProtocol, InputEncoding: UnicodeCodec, OutputEncoding: UnicodeCodec>
>        (_ input: Input, from inputEncoding: InputEncoding.Type, to outputEncoding: OutputEncoding.Type, stoppingOnError stopOnError: Bool, sendingOutputTo processCodeUnit: @noescape (OutputEncoding.CodeUnit) -> Void) -> Bool
>        where InputEncoding.CodeUnit == Input.Element
> 
> The detail in the `where` clause really is of secondary importance, especially compared to how much syntax it takes to specify, while this:
> 
>    public func transcode
>        <Input, InputEncoding, OutputEncoding>(_ input: Input, from inputEncoding: InputEncoding.Type, to outputEncoding: OutputEncoding.Type, stoppingOnError stopOnError: Bool, sendingOutputTo processCodeUnit: @noescape (OutputEncoding.CodeUnit) -> Void) -> Bool
>        where Input: IteratorProtocol, InputEncoding: UnicodeCodec, OutputEncoding: UnicodeCodec, InputEncoding.CodeUnit == Input.Element
> 
> Leaves far too much unspecified until the end.

Purely a matter of opinion... I'm fine with it.

> 
> I'm actually tempted to suggest that a conformance should be *mandatory* and you should have to specify `Any` if you don't have anything more specific to say about the generic parameter:
> 
>    func map<T: Any>(@noescape transform: (Element) throws -> T) rethrows -> [T]
> 
> That would penalize the "leave everything until the end" style without actually introducing any arbitrary rules forbidding it.
> 
> -- 
> Brent Royal-Gordon
> Architechies
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution


More information about the swift-evolution mailing list