on Tue, 21 Nov 2017 11:06:04 +0100 Tino Heth <[email protected]> wrote:
>
> > 5. func fn<T>[foo, bar](param: T) throws -> T where T: Equatable
> captures [foo, bar] { … }
>
> I guess it can be considered good practice to start a line with the most
> important information, and move the details to the far right, so that they
> don’t distract the hasty reader.
> I’m not sure if the capture list an example for this, but for good or
> worse, it didn’t draw much attention in another position either (the first
> „[foo, bar]“ that slipped through).
>
> That variant (func fn<T>[foo, bar](param: T)) is definitely my favorite,
> because it keeps a characteristic of closures (first the capture list, then
> the parameters), but doesn’t carry over the mingling of body and parameters
> that has to be done in closures.
>
maybe this?
{
capture weak foo, loo, poo // "capture list", if present
capture unowned bar, baz, booz // shall be at the beginning
capture weak delegate = self.delegate! // before anything else
foo()
...
}
compare to the current:
{
[
weak foo, weak loo, weak poo
unowned bar, unowned baz, unowned booz
weak delegate = self.delegate!
] in
foo()
...
}
a bit more explicit / expressive, looks like ordinary statements, and
doesn't have that strange "in" at the end.
Mike
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution