aboutsummaryrefslogtreecommitdiff
path: root/core/coroutines.nom
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2019-01-14 15:42:48 -0800
committerBruce Hill <bruce@bruce-hill.com>2019-01-14 15:43:24 -0800
commitc1c32688a4afc43f6addb99b8b5fa878944a70e3 (patch)
treec886f21b5b08a9053aa74fcba4b241dae5ede76d /core/coroutines.nom
parent2309b696fc34b24f05f6658b94f9105ca8ee76e4 (diff)
Overhaul in progress, mostly working. Moved all the nomsu packages into
lib/, including core/*. Changes to how nomsu environments and importing work.
Diffstat (limited to 'core/coroutines.nom')
-rw-r--r--core/coroutines.nom40
1 files changed, 0 insertions, 40 deletions
diff --git a/core/coroutines.nom b/core/coroutines.nom
deleted file mode 100644
index 6a99f7e..0000000
--- a/core/coroutines.nom
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/usr/bin/env nomsu -V6.14
-#
- This file defines the code that creates and manipulates coroutines
-
-use "core/metaprogramming"
-use "core/operators"
-use "core/control_flow"
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-test:
- $co =
- ->:
- yield 4
- yield 5
- repeat 3 times:
- yield 6
- $nums = []
- for $ in coroutine $co:
- $nums, add $
-
- unless ($nums == [4, 5, 6, 6, 6]):
- fail "Coroutine iteration failed"
-
- $d = {.x = 0}
- $co2 =
- coroutine:
- $d.x += 1
- yield 1
- $d.x += 1
- yield
- $d.x += 1
- repeat while ((coroutine status of $co2) != "dead"): resume $co2
- assume $d.x == 3
-(coroutine $body) parses as (coroutine from (-> $body))
-(for $ in coroutine $co $body) compiles to ("
- for \($ as lua expr) in coroutine_wrap(\($co as lua expr)) do
- \($body as lua)
- end
-")