[swift-evolution] Interspersing guard let with guard boolean

Erica Sadun erica at ericasadun.com
Fri May 13 13:27:16 CDT 2016


> On May 13, 2016, at 12:23 PM, Joe Groff <jgroff at apple.com> wrote:
> 
> 
>> On May 13, 2016, at 11:15 AM, Erica Sadun via swift-evolution <swift-evolution at swift.org> wrote:
>> 
>> Is there a technical reason that Swift cannot be expanded to allow arbitrary mixes of conditional binding and boolean assertions within a single compound guard statement?
> 
> No. You already can, we just have the somewhat strange rule that to separate `guard` conditions uses `,` before optional or pattern conditions, but `where` before boolean conditions:
> 
> 	guard x == 0,
> 	  let y = optional where
> 	  z == 2 {
> 	}
> 
> There's no technical reason we couldn't accept either 'where' or ',' consistently.
> 
> -Joe

Is it worth a proposal to allow both, for when the where clauses don't have to be semantically tied to the conditional binding?

-- E

/ccing  in Mike Ash so he can gloat



More information about the swift-evolution mailing list