> On May 20, 2016, at 8:01 PM, Erica Sadun via swift-evolution > <[email protected]> wrote: > > >> On May 20, 2016, at 11:53 AM, Matthew Johnson <[email protected] >> <mailto:[email protected]>> wrote: >> I am less certain about allowing simple boolean expressions that are not >> introduced by the `where` keyword (excepting the first one which is >> introduced with the `guard` keyword). I think this is a separate question >> that should receive independent consideration. I think a reasonable >> argument can be made both ways. > > That's kind of the heart of the matter. > > There's an assumption that guard statements are: > > `guard` (conjoined boolean tests) | (conjoined boolean tests,)? (pattern | > binding (where boolean)?, )+ else {...} > > Right? (Except I couldn't figure out how to grammar out the final comma,) I'm > suggesting: > > `guard` ((boolean | (pattern | binding (where boolean)?)),)+ else {...} > > instead. (And ditto about final comma) This promotes boolean statements to > the same standing, so they're not limited to the start of the guard statement > or syntactically tied to a pattern/binding where there may be no semantic > basis. > > -- E > > >
GRAMMAR OF A GUARD STATEMENT <>guard-statement → guardcondition-clause <https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Statements.html#//apple_ref/swift/grammar/condition-clause>elsecode-block <https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Declarations.html#//apple_ref/swift/grammar/code-block> <>condition-clause → expression <https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Expressions.html#//apple_ref/swift/grammar/expression> <>condition-clause → expression <https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Expressions.html#//apple_ref/swift/grammar/expression>,condition-list <https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Statements.html#//apple_ref/swift/grammar/condition-list> <>condition-clause → condition-list <https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Statements.html#//apple_ref/swift/grammar/condition-list> <>condition-clause → availability-condition <https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Statements.html#//apple_ref/swift/grammar/availability-condition>,expression <https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Expressions.html#//apple_ref/swift/grammar/expression> <>condition-list → condition <https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Statements.html#//apple_ref/swift/grammar/condition> condition <https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Statements.html#//apple_ref/swift/grammar/condition>,condition-list <https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Statements.html#//apple_ref/swift/grammar/condition-list> <>condition → availability-condition <https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Statements.html#//apple_ref/swift/grammar/availability-condition> case-condition <https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Statements.html#//apple_ref/swift/grammar/case-condition> optional-binding-condition <https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Statements.html#//apple_ref/swift/grammar/optional-binding-condition> <>case-condition → casepattern <https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Patterns.html#//apple_ref/swift/grammar/pattern>initializer <https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Declarations.html#//apple_ref/swift/grammar/initializer>where-clause <https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Statements.html#//apple_ref/swift/grammar/where-clause>opt it is all shared at the moment. /// stmt-guard: /// 'guard' condition 'else' stmt-brace /// ParserResult<Stmt> Parser::parseStmtGuard() { SourceLoc GuardLoc = consumeToken(tok::kw_guard); ... I guess it means that stepping out of what it currently does is straightforward to isolate from side effects, but likely a significant piece of work if it is not make a superset (meaning that bits and parts or the way the current grammar is structured can be reused in the manner they are today) of what it is today. > > > > > _______________________________________________ > 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
