[swift-evolution] Property Getter Return Statement

Xiaodi Wu xiaodi.wu at gmail.com
Sat Oct 7 10:24:26 CDT 2017


This has been brought up on the list before. For instance:

https://github.com/apple/swift-evolution/pull/608

Chris Lattner’s response at that time was:

‘Just MHO, but I consider this syntactic sugar, not a fundamental feature
that fits the goal of Swift 4 stage 2.

‘I’m also pretty opposed to doing it at any time. The rationale of
“implicit return” in closures is specifically because they are limited to a
single expression, which makes the semantics “obvious”. This was carefully
considered.’


On Sat, Oct 7, 2017 at 09:18 Nevin Brackett-Rozinsky via swift-evolution <
swift-evolution at swift.org> wrote:

> +1
>
> We don’t need “return” in single-line closures where the type is known,
> and I don’t see why it is required in single-line getters.
>
> Nevin
>
>
> On Sat, Oct 7, 2017 at 10:07 AM, James Valaitis via swift-evolution <
> swift-evolution at swift.org> wrote:
>
>> Is it widely agreed that it is necessary to require a return statement on
>> a one line property getter?
>>
>> var session: AVCaptureSession { get { return layer.session } }
>>
>> Or could we follow the convention for any other close and get rid of it?
>> For me it seems redundant; the word `get` literally precedes the closure.
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org
>> 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/20171007/68d0bea1/attachment.html>


More information about the swift-evolution mailing list