[swift-evolution] [Pitch] Make `return` optional in computed properties for a single case

L Mihalkovic laurent.mihalkovic at gmail.com
Tue May 31 14:32:01 CDT 2016


> On May 31, 2016, at 8:45 PM, Adrian Zubarev via swift-evolution <swift-evolution at swift.org> wrote:
> 
> I feel like return is very important part of guard statement. I understand the requirement for consistency with properties/closures/functions, but I’ll prefer to have some inconsistency in language in this case and require return for guard. And in case I’ll have to choose all-or-nothig, I’ll give –1 for the proposal. 
> What’s the problem with single-expression guards? guard cannot fall trough and the type is inferred as the same as its parent closure has. 
> 
> If we’d like to have this consistence everywhere in the language, guards will be part of that as well.
> 
> I’d interpret that as being able to write:
> 
> var x: Int8 { 20 }
> as opposed to:
> var x: Int8 { Int8(20) }
> Comment:
> 
> Integer literals are untyped and pick up the type of their context.
> 
> Joe Groff <https://twitter.com/jckarter/status/649275500506955780>
> 
so there is no way to draw a parallel between integer literals and say ‘value’ ?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160531/280da470/attachment.html>


More information about the swift-evolution mailing list