diff options
Diffstat (limited to 'examples/guard.fwd')
| -rw-r--r-- | examples/guard.fwd | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/examples/guard.fwd b/examples/guard.fwd deleted file mode 100644 index df42ef3..0000000 --- a/examples/guard.fwd +++ /dev/null @@ -1,40 +0,0 @@ -/* 'auto' is a special type that currently is in place of generics, will - * eventually be replaced but this is good enough to play around with */ -fwd_println(auto s); - -/* this is a hack, just creates two copies of whatever is passed to it. - * Primitive types should probably be excluded from the move checking, and more - * complex types would presumably implement some kind of .copy(), but at the - * moment that's still TODO */ -fwd_copy(auto n, (auto, auto) n1); - -guard(bool cond, () err, () ok) -{ - if cond { - err(); - } else { - ok(); - } -} - -try_print_one(int a) -{ - fwd_copy(a) => int a1, int a2; - guard(a1 < 1) => { - fwd_println("smaller than 1"); - } => ; - - fwd_copy(a2) => int a3, int a4; - guard(a3 > 1) => { - fwd_println("larger than 1"); - } => ; - - fwd_println(a4); -} - -main() -{ - try_print_one(0); - try_print_one(1); - try_print_one(2); -} |
