File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Support ` ... ` in match cases
2
+
3
+ * Proposal: [ ME-0003] ( https://github.com/moonbitlang/moonbit-evolution/blob/0003-todo-cases/proposals/0003-todo-cases.mbt.md )
4
+ * Author: [ Yu-zh] ( https://github.com/Yu-zh )
5
+ * Review and discussion: [ Github issue] ( https://github.com/moonbitlang/moonbit-evolution/pull/4 )
6
+
7
+ ## Introduction
8
+
9
+ In MoonBit, we can use ` ... ` as a placeholder for unimplemented code. For example:
10
+ ``` moonbit
11
+ fn init {
12
+ fn unimplemented() {
13
+ ...
14
+ }
15
+ }
16
+ ```
17
+
18
+ The compiler emits a warning when the ` ... ` is used, but the code will be
19
+ further compiled. If ` ... ` is reached at runtime, the program will panic.
20
+
21
+ ## Allow ` ... ` in match cases
22
+
23
+ Currently, ` ... ` is only allowed when a statement is expected. Therefore, if we
24
+ want leave the code in match cases unimplemented, we have to write ` _ => ... ` :
25
+ ``` moonbit
26
+ pub fn f1(x: Int) -> Unit {
27
+ match x {
28
+ 0 => ()
29
+ _ => ...
30
+ }
31
+ }
32
+ ```
33
+
34
+ We propose to extend the support to match cases so that we can write ` ... `
35
+ directly:
36
+ ``` moonbit
37
+ pub fn f2(x: Int) -> Unit {
38
+ match x {
39
+ 0 => ()
40
+ ...
41
+ }
42
+ }
43
+ ```
You can’t perform that action at this time.
0 commit comments