[swift-evolution] [Pitch] making where and , interchangeable in guard conditions.

Erica Sadun erica at ericasadun.com
Tue May 24 13:19:29 CDT 2016


Right now, if you look at the grammar, it's pretty hard to follow and special cased. 
I think if people follow an intentional pattern of a condition per line (including where clauses)
they won't get in trouble. (Also Swift is a lot smarter about inadvertent = vs ==)

-- E


> On May 24, 2016, at 11:59 AM, Austin Zheng <austinzheng at gmail.com> wrote:
> 
> I like the idea in principle.
> 
> However, right now you can write something like:
> 
> if let a = optionalA, frob = fooBarBaz() { ... }
> 
> It's clear that both clauses are optional binding clauses.
> 
> With this change, it's not clear anymore whether the second clause is an optional binding clause, or a logic test erroneously using '=' instead of '=='.
> 
> To be fair, though, since assignment in Swift doesn't return the new value as it does in C, there is far less room for disastrous bugs caused by this sort of mistake.
> 
> Austin
> 



More information about the swift-evolution mailing list