Conditional-expression/access syntax refinement.
Summary
Introduce whitespace-sensitive parsing rules to eliminate ambiguity between the conditional operator (?:)
and null-conditional access operators (?. and ?[). This change requires that tokens in null-conditional
operators must be adjacent with no intervening characters, while conditional operators with certain operand
patterns must have whitespace or comments between the ? and the subsequent token.
For example: a?[ will always be interpreted to be the start of a conditional index into a (e.g. a?[b]). In other words, indexing into a with some arguments that follow the [ if a is non-null. Whereas a? [ will always be interpreted to be the start of a condition expression (e.g. a ? [b] : ...). So a test if a is true or not, and returning a collection expression if so.
Design meetings
Conditional-expression/access syntax refinement.
Summary
Introduce whitespace-sensitive parsing rules to eliminate ambiguity between the conditional operator (
?:)and null-conditional access operators (
?.and?[). This change requires that tokens in null-conditionaloperators must be adjacent with no intervening characters, while conditional operators with certain operand
patterns must have whitespace or comments between the
?and the subsequent token.For example:
a?[will always be interpreted to be the start of a conditional index intoa(e.g.a?[b]). In other words, indexing intoawith some arguments that follow the[ifais non-null. Whereasa? [will always be interpreted to be the start of a condition expression (e.g.a ? [b] : ...). So a test ifais true or not, and returning a collection expression if so.Design meetings