[swift-evolution] Replace named returns with `out` parameters?
Dominik Pich
dominik at pich.info
Wed Dec 28 11:12:54 CST 2016
Totally against out params. Returning tuples is way more logical & understandable
BR
Dominik
Web: https://pich.info
Twitter: @DaijDjan
Facebook: Dominik.Pich
> On 28 Dec 2016, at 15:06, Daniel Leping via swift-evolution <swift-evolution at swift.org> wrote:
>
> -1 here. What's wrong with tuples? Don't kill functional approach
>
> On Wed, 28 Dec 2016 at 19:35 Micah Hainline via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
> 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 <mailto: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 <mailto:swift-evolution at swift.org>
>> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
> _______________________________________________
>
> swift-evolution mailing list
>
> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
>
> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
>
> _______________________________________________
> 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/564edfb4/attachment.html>
More information about the swift-evolution
mailing list