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?
Thanks, -- E
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
···
On May 13, 2016, at 11:15 AM, Erica Sadun via swift-evolution <swift-evolution@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?
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
···
On May 13, 2016, at 12:23 PM, Joe Groff <jgroff@apple.com> wrote:
On May 13, 2016, at 11:15 AM, Erica Sadun via swift-evolution <swift-evolution@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