You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We allow if (e case p when e) ... as statements and elements, but not in as expressions, where conditional branching uses the ?/: operator.
I suggest we allow it, but require parentheses, so:
(e case p when e) ? ... : ....
becomes a valid expression.
It will not introduce any new expressive power, since [if (e case p when e) ... else ...].first does precisely the same thing, just with more memory overhead. It completes the orthogonality of the feature, by allowing it in every branch construct.
(Can also be allowed in a while-loop condition, with a true scope covering the body of the while.)
The text was updated successfully, but these errors were encountered:
This seems reasonable to me too, but I agree with marking it "patterns-later" so we can get a feel for how the pattern matching features we've already specced fit into the ecosystem. I'm always worried about designing too far ahead of ourselves before we get real hands on feedback from how users adopt a feature. (I realize the irony of me saying that given the huge surface area of patterns already...)
It will not introduce any new expressive power, since [if (e case p when e) ... else ...].first does precisely the same thing
A nicer form of conditional expression would be (if (e case p when e) ... else...) , which is style-consistent with collection if, and remains valid if you later introduce if expression with no outer parentheses
We allow
if (e case p when e) ...
as statements and elements, but not in as expressions, where conditional branching uses the?
/:
operator.I suggest we allow it, but require parentheses, so:
becomes a valid expression.
It will not introduce any new expressive power, since
[if (e case p when e) ... else ...].first
does precisely the same thing, just with more memory overhead. It completes the orthogonality of the feature, by allowing it in every branch construct.(Can also be allowed in a
while
-loop condition, with atrue
scope covering the body of thewhile
.)The text was updated successfully, but these errors were encountered: