One complication with allowing postfix conditionals for all statements is that 
it often needs to have an else clause as well (like the ternary operator “?:").

For example, what’s the type of “x” below?

let x = 5 if someCriteria()

And is “y” initialized or not?

let y: Int
y = 42 if someCriteria()
doSomething(with: y)

I realize that this idea is more about the feature/behavior than the naming, 
but renaming “guard” to “unless” is one of the commonly rejected proposals.
https://github.com/apple/swift-evolution/blob/master/commonly_proposed.md

- David


> On 04 Aug 2016, at 16:52, Kurt Werle via swift-evolution 
> <[email protected]> wrote:
> 
> Why would you do this just for return statements?  Why not do postfix 
> conditionals for all statements (like ruby)?
> 
> I've always liked postfix conditionals, but not enough to suggest them.  
> Mostly I'm curious about limiting the scope to return statements.
> 
> On Thu, Aug 4, 2016 at 7:31 AM, Christian Kienle via swift-evolution 
> <[email protected] <mailto:[email protected]>> wrote:
> +1
> 
> 2016-08-04 15:38 GMT+02:00 Julian Dunskus via swift-evolution 
> <[email protected] <mailto:[email protected]>>:
> How often have you written something like the following?
> 
> `
> if indexPath.row == 0 { return }
> 
> guard let thing = things[index] else { return nil }
> `
> 
> I propose adding some syntactic sugar to make such statements more readable 
> and simple to write:
> 
> `
> return if indexPath.row == 0
> 
> return nil unless let thing = things[index]
> `
> 
> I don’t know how easy or hard this would be to implement, but I think it 
> would improve some code significantly.
> 
> –Julian Dunskus
> 
> _______________________________________________
> swift-evolution mailing list
> [email protected] <mailto:[email protected]>
> https://lists.swift.org/mailman/listinfo/swift-evolution 
> <https://lists.swift.org/mailman/listinfo/swift-evolution>
> 
> 
> 
> 
> -- 
> Mit freundlichen Grüßen
> 
> Christian Kienle
> Mobile Developer
> 
> REWE Digital GmbH
> Domstraße 20, 50668 Köln, Büro: Schanzenstr. 6-20, 51063 Köln
> Geschäftsführer: Dr. Jean-Jacques Michel van Oosten (Vorsitzender), Christoph 
> Eltze, Dr. Johannes Steegmann, Dr. Robert Zores
> Handelsregister: Amtsgericht Köln (HRB 78670) UST-ID-Nr.: DE 290 605 450
> 
> Telefon: +49 151 11441782
> E-Mail: [email protected] 
> <mailto:[email protected]>
> Internet: www.rewe-digital.com <http://www.rewe-digital.com/>
> 
> Ein Unternehmen der REWE GROUP
> http://www.rewe-group.com <http://www.rewe-group.com/>
> _______________________________________________
> swift-evolution mailing list
> [email protected] <mailto:[email protected]>
> https://lists.swift.org/mailman/listinfo/swift-evolution 
> <https://lists.swift.org/mailman/listinfo/swift-evolution>
> 
> 
> 
> 
> -- 
> [email protected]
> http://www.CircleW.org/kurt/ <http://www.circlew.org/kurt/>
> _______________________________________________
> swift-evolution mailing list
> [email protected]
> https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to