aboutsummaryrefslogtreecommitdiff
path: root/core/coroutines.nom
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2018-11-09 14:36:15 -0800
committerBruce Hill <bruce@bruce-hill.com>2018-11-09 14:37:22 -0800
commit7d2b7199d87930096b7fd799709fe0105d51eccb (patch)
treef33de61cb44357497758bb08ec6993753d8baa43 /core/coroutines.nom
parentba96cdfa07cea15ada62f8f89b2563de1286a0de (diff)
Lots of cleanups, including expanded use of (... compiles to "text
literal") shorthand, deprecating Lua value, and more use of Lua "..." with text interpolations.
Diffstat (limited to 'core/coroutines.nom')
-rw-r--r--core/coroutines.nom21
1 files changed, 9 insertions, 12 deletions
diff --git a/core/coroutines.nom b/core/coroutines.nom
index f03cfc8..782c20e 100644
--- a/core/coroutines.nom
+++ b/core/coroutines.nom
@@ -16,16 +16,13 @@ test:
for % in coroutine %co: %nums::add %
assume (%nums == [4, 5, 6, 6, 6]) or barf "Coroutine iteration failed"
-[coroutine %body, generator %body] all compile to (..)
- Lua value "\
- ..(function()
- \(%body as lua statements)
- end)"
+[coroutine %body, generator %body] all compile to "\
+ ..(function()
+ \(%body as lua statements)
+ end)"
-(->) compiles to (Lua value "coroutine.yield(true)")
-(-> %) compiles to (Lua value "coroutine.yield(true, \(% as lua expr))")
-(for % in coroutine %co %body) compiles to (..)
- Lua "\
- ..for junk,\(% as lua expr) in coroutine.wrap(\(%co as lua expr)) do
- \(%body as lua statements)
- end"
+(-> %) compiles to "coroutine.yield(true, \((% as lua expr) if % else "nil"))"
+(for % in coroutine %co %body) compiles to "\
+ ..for _junk,\(% as lua expr) in coroutine.wrap(\(%co as lua expr)) do
+ \(%body as lua statements)
+ end"