diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2026-05-01 22:43:13 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2026-05-01 22:43:13 +0300 |
| commit | db3809488805fbdcd9d726d9ed45ad7335812bd1 (patch) | |
| tree | dcf1ceb68a7d77733a474825a9804fe99d253b48 /examples/guard.fwd | |
| parent | f1e9860ab638594e95db0ada848157b860eeb831 (diff) | |
| download | fwd-db3809488805fbdcd9d726d9ed45ad7335812bd1.tar.gz fwd-db3809488805fbdcd9d726d9ed45ad7335812bd1.zip | |
+ Might come up with proper examples at some point, but for now tests at
least tell us if they're broken
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); -} |
