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

Pyry Jahkola pyry.jahkola at iki.fi
Mon May 16 03:48:13 CDT 2016

> On 16 May 2016, Thorsten Seitz wrote:
> Funny, for me reading a function is quite the other way around:
> I prefer to first look at the function name and parameter list to give me an idea of what the function will do (the parameter names help a lot).
> Having instead first to memorize a list of types with all their constraints just builds up the cognitive load without helping much, because their usage is yet unknown.

This is also my biggest motivation for the proposal: keeping the function name and arguments close to each other.

> So, for me reading the signature would look like (with the proposal in place):
>>> internal func _arrayOutOfPlaceReplace<B,C>(_ source: inout B, _ bounds: Range<Int>, _ newValues: C, _ insertCount: Int)

^ Agreed! That's essentially what I'm trying to find too when skimming through code.

An alternative approach with the same desired outcome would be moving the parameter list before the function name, either `func<...> someFunction(...)`, or even before the `func` keyword. But since we already use `where`, it seems more natural to me for Swift to place the constraints list to the end.

— Pyry

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

More information about the swift-evolution mailing list