[swift-evolution] Replace named returns with `out` parameters?

Micah Hainline micah.hainline at gmail.com
Wed Dec 28 08:02:37 CST 2016

You haven't really explained what problem this solves, and it would have to be a pretty big one to justify such a change.

I'm -1 on this, until a compelling argument is made. This feels like just liking the syntax of another language and wanting it in Swift.

> On Dec 28, 2016, at 5:09 AM, Anton Zhilin via swift-evolution <swift-evolution at swift.org> wrote:
> Some people on the list wondered, why we have moved from tuples in function parameters, but multiple returns are still implemented using tuples? The following code still compiles:
> func position() -> (x: Int, y: Int) {
>     return (x: 0, y: 0)
> }
> let (y, x) = position()
> (Maybe it’s a bad example, because naturally we’d use Point struct. Let’s pretend those two parameters don’t make sense as a struct.)
> What I want to discuss is if we should introduce out parameters and make them the default for multiple returns for Swift 4. The syntax would look like:
> func position(x: out Int, y: out Int) {
>     x = 0
>     y = 0
> }
> var y
> position(x: let x, y: y)
> out arguments can be any patterns allowed on the left side of assignment, including wildcard pattern and tuple destructuring pattern.
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20161228/6e86281f/attachment.html>

More information about the swift-evolution mailing list