Implement #complete switch by default, replace with #partial switch #511

This commit is contained in:
gingerBill
2019-12-22 12:03:48 +00:00
parent 4593730632
commit d1c9fd4e01
19 changed files with 263 additions and 227 deletions
+15 -5
View File
@@ -7,6 +7,7 @@ import "core:thread"
import "core:reflect"
import "intrinsics"
/*
The Odin programming language is fast, concise, readable, pragmatic and open sourced.
It is designed with the intent of replacing C with the following goals:
@@ -1233,8 +1234,8 @@ implicit_selector_expression :: proc() {
}
complete_switch :: proc() {
fmt.println("\n# complete_switch");
partial_switch :: proc() {
fmt.println("\n# partial_switch");
{ // enum
Foo :: enum {
A,
@@ -1244,22 +1245,31 @@ complete_switch :: proc() {
};
f := Foo.A;
#complete switch f {
switch f {
case .A: fmt.println("A");
case .B: fmt.println("B");
case .C: fmt.println("C");
case .D: fmt.println("D");
case: fmt.println("?");
}
#partial switch f {
case .A: fmt.println("A");
case .D: fmt.println("D");
}
}
{ // union
Foo :: union {int, bool};
f: Foo = 123;
#complete switch in f {
switch in f {
case int: fmt.println("int");
case bool: fmt.println("bool");
case:
}
#partial switch in f {
case bool: fmt.println("bool");
}
}
}
@@ -1820,7 +1830,7 @@ main :: proc() {
array_programming();
map_type();
implicit_selector_expression();
complete_switch();
partial_switch();
cstring_example();
bit_set_type();
deferred_procedure_associations();