From b3df63eb1044a740e205524aaa37bebe08bd169e Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 30 May 2018 14:08:03 -0700 Subject: Added 'for (%k,%v) in ...' alias for 'for %k = %v in ...' --- core/control_flow.nom | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'core/control_flow.nom') diff --git a/core/control_flow.nom b/core/control_flow.nom index 5eabefd..e54f10a 100644 --- a/core/control_flow.nom +++ b/core/control_flow.nom @@ -76,10 +76,10 @@ immediately (function() for \(%subtree as lua expr) in coroutine.wrap(function() \(%tree as lua expr):map(coroutine.yield) end) do if \(%condition as lua expr) then - return true; + return true end end - return false; + return false end)() # While loops @@ -207,7 +207,10 @@ immediately # Dict iteration (lua's "pairs()") immediately - compile [for %key = %value in %iterable %body] to + compile [..] + for %key = %value in %iterable %body + for (%key,%value) in %iterable %body + ..to # This uses Lua's approach of only allowing loop-scoped variables in a loop assume (%key.type is "Var") or barf "Loop expected variable, not: \%key" assume (%value.type is "Var") or barf "Loop expected variable, not: \%value" -- cgit v1.2.3