> On Oct 8, 2017, at 21:56, Slava Pestov via swift-evolution 
> <swift-evolution@swift.org> wrote:
> 
> 
> 
>> On Oct 7, 2017, at 7:07 AM, James Valaitis via swift-evolution 
>> <swift-evolution@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.
> 
> In multi-file projects, re-compiling one file that references the property 
> would necessitate type checking the body of the getter, even if the getter is 
> defined in a different source file. So one reason not to have this would be 
> to avoid slowing down type checking.

This is not correct. Omitting the "return" is different from omitting the 
property's type.

(I'm minorly in favor of allowing the 'return' to be omitted for 
single-expression getters. Not enough to be the person who implements it, but 
enough to +1 a proposal-with-implementation even in the Swift 5 timeframe.)

Jordan

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to