aboutsummaryrefslogtreecommitdiff
path: root/nim/step6_file.nim
diff options
context:
space:
mode:
Diffstat (limited to 'nim/step6_file.nim')
-rw-r--r--nim/step6_file.nim9
1 files changed, 6 insertions, 3 deletions
diff --git a/nim/step6_file.nim b/nim/step6_file.nim
index 53269aa..6f0e02a 100644
--- a/nim/step6_file.nim
+++ b/nim/step6_file.nim
@@ -26,7 +26,7 @@ proc eval(ast: MalType, env: var Env): MalType =
case f.kind
of MalFun:
ast = f.malfun.ast
- env = initEnv(f.malfun.env, f.malfun.params, list(el.list[1 .. -1]))
+ env = initEnv(env, f.malfun.params, list(el.list[1 .. -1]))
else:
return f.fun(el.list[1 .. -1])
@@ -49,11 +49,14 @@ proc eval(ast: MalType, env: var Env): MalType =
let
a1 = ast.list[1]
a2 = ast.list[2]
+ var let_env = Env(env)
case a1.kind
of List, Vector:
for i in countup(0, a1.list.high, 2):
- env.set(a1.list[i].str, a1.list[i+1].eval(env))
- else: discard
+ let_env.set(a1.list[i].str, a1.list[i+1].eval(let_env))
+ else: raise newException(ValueError, "Illegal kind in let*")
+ ast = a2
+ env = let_env
# Continue loop (TCO)
of "do":