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
I originally proposed to have the braces in case expression optional -- to be used only for disambiguation with nested cases avoiding the awkward parentheses around the nested case. However, non-nested cases are the most common use-case. A syntax without braces seems to fit better with the overall feel of the language. We don't have braces in let or type.
I think this issue resurfaces now with the implementation of multi-way if, where braces are neither planned nor needed:
To keep the syntax consistent, allowing to omit braces in case would make sense. Also, in the most common situation braces in case are not necessary - omitting them would make the syntax more concise. We would keep the option to have them only for disambiguation of nested cases.
Hence, I propose to allow also
case x of
| pat1 := expr1
| pat2 := expr2
in addition to
case x of {
| pat1 := expr1
| pat2 := expr2
}
This poses no problems in parsing -- we have two possibilities which can be distinguished by one lookahead token ({). I imagine one would normally use the version without braces, except to disambiguate a nested case.
The text was updated successfully, but these errors were encountered:
We should clean up and fix the case syntax. I see the old case syntax without braces but also without of is still supported. We should decide on a more uniform syntax, and remove the old syntaxes. My proposal is above.
In the issue
I originally proposed to have the braces in case expression optional -- to be used only for disambiguation with nested cases avoiding the awkward parentheses around the nested case. However, non-nested cases are the most common use-case. A syntax without braces seems to fit better with the overall feel of the language. We don't have braces in
let
ortype
.I think this issue resurfaces now with the implementation of multi-way
if
, where braces are neither planned nor needed:if
syntax #2736To keep the syntax consistent, allowing to omit braces in
case
would make sense. Also, in the most common situation braces incase
are not necessary - omitting them would make the syntax more concise. We would keep the option to have them only for disambiguation of nested cases.Hence, I propose to allow also
in addition to
This poses no problems in parsing -- we have two possibilities which can be distinguished by one lookahead token (
{
). I imagine one would normally use the version without braces, except to disambiguate a nested case.The text was updated successfully, but these errors were encountered: