Initial Commit
This commit is contained in:
706 files changed
+135430
No files matched your search
@@ -0,0 +1,27 @@
|
||||
import std::io;
|
||||
struct nothing {}
|
||||
union value { var none: nothing; var number: i64; var text: span<u8>; }
|
||||
type kind = u8;
|
||||
val kind::text := 2;
|
||||
struct holder { val name: span<u8>; var held: value; }
|
||||
def shout(text: span<u8>): string { return $"{text}!"; }
|
||||
def check(kind: kind): bool { return kind == kind::text; }
|
||||
def loud(text: span<u8>): string { return $"{text}!"; }
|
||||
def main(): void {
|
||||
val word := "hey";
|
||||
print($"{loud("a")} {shout($"b{1}")} ");
|
||||
val spoken := shout(word);
|
||||
var h := holder{ name = spoken };
|
||||
var v: value;
|
||||
print($"{h.name} {h.held is none} {v is none} {check(2)} {check(3)} ");
|
||||
h.held.number = 5;
|
||||
var n := 1;
|
||||
var i := 0;
|
||||
while i < 2 {
|
||||
val target := i == 0 ? &mut n as *mut int : null;
|
||||
if target != null { target[0] = 9; }
|
||||
print($"{target == null} ");
|
||||
i++;
|
||||
}
|
||||
println($"{n} {h.held}");
|
||||
}
|
||||
Reference in new issue
Block a user