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

Haravikk swift-evolution at haravikk.me
Sat May 14 11:29:40 CDT 2016

> On 14 May 2016, at 16:52, Tony Allevato via swift-evolution <swift-evolution at swift.org> wrote:
> To me, this makes declarations with complex sets of constraints much harder to read, because I have to hunt them down instead of finding them all in one place. Under this proposal, the longer an argument list gets, the further separated the constraints are from the type parameters that use them.

This is partly an issue of how you use the feature rather than an issue with the feature itself, as you’re assuming that everything is all on one line, but really I think the intent of this feature is to better support multi-line declarations. It enables things like:

	func someMethod<S:SequenceType, T>(value:S) -> AnySequence<T>
		where S.Generator.Element == T { … }

The actual function signature stays on the top, but the constraint can now move down neatly, since it’s a supplementary condition that you may not to consider right away, or at all, if it’s just reinforcing some kind of common-sense limitation.

This is partly why I’d prefer to see it optional though, as some things will fit on one line reasonably well (you probably could with the above for example), but like you say, with it all on one line the return type becomes less visible.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160514/39cdb7a0/attachment.html>

More information about the swift-evolution mailing list