diff --git a/impls/io/step2_eval.io b/impls/io/step2_eval.io index 1b9e86e455..7f039e06dd 100644 --- a/impls/io/step2_eval.io +++ b/impls/io/step2_eval.io @@ -8,7 +8,7 @@ eval_ast := method(ast, env, EVAL := method(ast, env, - # "EVAL: " .. PRINT(ast)) println + // "EVAL: " .. PRINT(ast) println (ast type) switch( "MalSymbol", return(env at(ast val) ifNil(Exception raise("'" .. (ast val) "' not found"))), diff --git a/impls/scala/step2_eval.scala b/impls/scala/step2_eval.scala index 8d926a9ca1..28fd62f9b6 100644 --- a/impls/scala/step2_eval.scala +++ b/impls/scala/step2_eval.scala @@ -1,4 +1,4 @@ -import types.{MalList, _list_Q, MalVector, MalHashMap, MalFunction} +import types.{MalList, _list_Q, MalVector, MalHashMap, Func} object step2_eval { // read @@ -7,7 +7,7 @@ object step2_eval { } // eval - def eval_ast(ast: Any, env: Map[Symbol,Any]): Any = { + def EVAL(ast: Any, env: Map[Symbol,Any]): Any = { // println("EVAL: " + printer._pr_str(ast,true)) @@ -32,10 +32,10 @@ object step2_eval { // function call EVAL(first, env) match { case fn: Func => { - el = rest.map(EVAL(_, env)) + val el = rest.map(EVAL(_, env)) return fn(el) } - case _ => { + case f => { throw new Exception("attempt to call non-function: " + f) } } diff --git a/impls/scala/step3_env.scala b/impls/scala/step3_env.scala index 5815155139..0f4afd1583 100644 --- a/impls/scala/step3_env.scala +++ b/impls/scala/step3_env.scala @@ -1,4 +1,4 @@ -import types.{MalList, _list_Q, MalVector, MalHashMap, MalFunction} +import types.{MalList, _list_Q, MalVector, MalHashMap, Func} import env.Env object step3_env { @@ -8,10 +8,10 @@ object step3_env { } // eval - def eval_ast(ast: Any, env: Env): Any = { + def EVAL(ast: Any, env: Env): Any = { - if (env.find(Symbol("DEBUG-EVAL"))) { - dbgeval = env.get(Symbol("DEBUG-EVAL")) + if (env.find(Symbol("DEBUG-EVAL")) != null) { + val dbgeval = env.get(Symbol("DEBUG-EVAL")) if (dbgeval != null && dbgeval != false) { println("EVAL: " + printer._pr_str(ast,true)) } @@ -48,10 +48,10 @@ object step3_env { // function call EVAL(first, env) match { case fn: Func => { - el = rest.map(EVAL(_, env)) + val el = rest.map(EVAL(_, env)) return fn(el) } - case _ => { + case f => { throw new Exception("attempt to call non-function: " + f) } } diff --git a/impls/scala/step4_if_fn_do.scala b/impls/scala/step4_if_fn_do.scala index 4b2a1cfce9..5f3c831c1b 100644 --- a/impls/scala/step4_if_fn_do.scala +++ b/impls/scala/step4_if_fn_do.scala @@ -9,10 +9,10 @@ object step4_if_fn_do { } // eval - def eval_ast(ast: Any, env: Env): Any = { + def EVAL(ast: Any, env: Env): Any = { - if (env.find(Symbol("DEBUG-EVAL"))) { - dbgeval = env.get(Symbol("DEBUG-EVAL")) + if (env.find(Symbol("DEBUG-EVAL")) != null) { + val dbgeval = env.get(Symbol("DEBUG-EVAL")) if (dbgeval != null && dbgeval != false) { println("EVAL: " + printer._pr_str(ast,true)) } @@ -67,10 +67,10 @@ object step4_if_fn_do { // function call EVAL(first, env) match { case fn: Func => { - el = rest.map(EVAL(_, env)) + val el = rest.map(EVAL(_, env)) return fn(el) } - case _ => { + case f => { throw new Exception("attempt to call non-function: " + f) } } diff --git a/impls/scala/step5_tco.scala b/impls/scala/step5_tco.scala index 6385a6d0bd..a09f2f84c6 100644 --- a/impls/scala/step5_tco.scala +++ b/impls/scala/step5_tco.scala @@ -13,8 +13,8 @@ object step5_tco { var ast = orig_ast; var env = orig_env; while (true) { - if (env.find(Symbol("DEBUG-EVAL"))) { - dbgeval = env.get(Symbol("DEBUG-EVAL")) + if (env.find(Symbol("DEBUG-EVAL")) != null) { + val dbgeval = env.get(Symbol("DEBUG-EVAL")) if (dbgeval != null && dbgeval != false) { println("EVAL: " + printer._pr_str(ast,true)) } @@ -72,15 +72,15 @@ object step5_tco { // function call EVAL(first, env) match { case fn: MalFunction => { - el = rest.map(EVAL(_, env)) + val el = rest.map(EVAL(_, env)) env = fn.gen_env(el) ast = fn.ast // continue loop (TCO) } case fn: Func => { - el = rest.map(EVAL(_, env)) + val el = rest.map(EVAL(_, env)) return fn(el) } - case _ => { + case f => { throw new Exception("attempt to call non-function: " + f) } } diff --git a/impls/scala/step6_file.scala b/impls/scala/step6_file.scala index 69219ad861..f8602922f3 100644 --- a/impls/scala/step6_file.scala +++ b/impls/scala/step6_file.scala @@ -13,8 +13,8 @@ object step6_file { var ast = orig_ast; var env = orig_env; while (true) { - if (env.find(Symbol("DEBUG-EVAL"))) { - dbgeval = env.get(Symbol("DEBUG-EVAL")) + if (env.find(Symbol("DEBUG-EVAL")) != null) { + val dbgeval = env.get(Symbol("DEBUG-EVAL")) if (dbgeval != null && dbgeval != false) { println("EVAL: " + printer._pr_str(ast,true)) } @@ -72,15 +72,15 @@ object step6_file { // function call EVAL(first, env) match { case fn: MalFunction => { - el = rest.map(EVAL(_, env)) + val el = rest.map(EVAL(_, env)) env = fn.gen_env(el) ast = fn.ast // continue loop (TCO) } case fn: Func => { - el = rest.map(EVAL(_, env)) + val el = rest.map(EVAL(_, env)) return fn(el) } - case _ => { + case f => { throw new Exception("attempt to call non-function: " + f) } } diff --git a/impls/scala/step7_quote.scala b/impls/scala/step7_quote.scala index 0eb77e732d..b25e564de4 100644 --- a/impls/scala/step7_quote.scala +++ b/impls/scala/step7_quote.scala @@ -50,8 +50,8 @@ object step7_quote { var ast = orig_ast; var env = orig_env; while (true) { - if (env.find(Symbol("DEBUG-EVAL"))) { - dbgeval = env.get(Symbol("DEBUG-EVAL")) + if (env.find(Symbol("DEBUG-EVAL")) != null) { + val dbgeval = env.get(Symbol("DEBUG-EVAL")) if (dbgeval != null && dbgeval != false) { println("EVAL: " + printer._pr_str(ast,true)) } @@ -115,15 +115,15 @@ object step7_quote { // function call EVAL(first, env) match { case fn: MalFunction => { - el = rest.map(EVAL(_, env)) + val el = rest.map(EVAL(_, env)) env = fn.gen_env(el) ast = fn.ast // continue loop (TCO) } case fn: Func => { - el = rest.map(EVAL(_, env)) + val el = rest.map(EVAL(_, env)) return fn(el) } - case _ => { + case f => { throw new Exception("attempt to call non-function: " + f) } } diff --git a/impls/scala/step8_macros.scala b/impls/scala/step8_macros.scala index 924eabe651..a980a55e09 100644 --- a/impls/scala/step8_macros.scala +++ b/impls/scala/step8_macros.scala @@ -50,8 +50,8 @@ object step8_macros { var ast = orig_ast; var env = orig_env; while (true) { - if (env.find(Symbol("DEBUG-EVAL"))) { - dbgeval = env.get(Symbol("DEBUG-EVAL")) + if (env.find(Symbol("DEBUG-EVAL")) != null) { + val dbgeval = env.get(Symbol("DEBUG-EVAL")) if (dbgeval != null && dbgeval != false) { println("EVAL: " + printer._pr_str(ast,true)) } @@ -123,16 +123,16 @@ object step8_macros { if (fn.ismacro) { ast = fn(rest) // continue loop (TCO) } else { - el = rest.map(EVAL(_, env)) + val el = rest.map(EVAL(_, env)) env = fn.gen_env(el) ast = fn.ast // continue loop (TCO) } } case fn: Func => { - el = rest.map(EVAL(_, env)) + val el = rest.map(EVAL(_, env)) return fn(el) } - case _ => { + case f => { throw new Exception("attempt to call non-function: " + f) } } diff --git a/impls/scala/step9_try.scala b/impls/scala/step9_try.scala index 6fed3444cf..fe4c70168c 100644 --- a/impls/scala/step9_try.scala +++ b/impls/scala/step9_try.scala @@ -50,8 +50,8 @@ object step9_try { var ast = orig_ast; var env = orig_env; while (true) { - if (env.find(Symbol("DEBUG-EVAL"))) { - dbgeval = env.get(Symbol("DEBUG-EVAL")) + if (env.find(Symbol("DEBUG-EVAL")) != null) { + val dbgeval = env.get(Symbol("DEBUG-EVAL")) if (dbgeval != null && dbgeval != false) { println("EVAL: " + printer._pr_str(ast,true)) } @@ -144,16 +144,16 @@ object step9_try { if (fn.ismacro) { ast = fn(rest) // continue loop (TCO) } else { - el = rest.map(EVAL(_, env)) + val el = rest.map(EVAL(_, env)) env = fn.gen_env(el) ast = fn.ast // continue loop (TCO) } } case fn: Func => { - el = rest.map(EVAL(_, env)) + val el = rest.map(EVAL(_, env)) return fn(el) } - case _ => { + case f => { throw new Exception("attempt to call non-function: " + f) } } diff --git a/impls/scala/stepA_mal.scala b/impls/scala/stepA_mal.scala index 5d6a2cdc22..e54a95fb5e 100644 --- a/impls/scala/stepA_mal.scala +++ b/impls/scala/stepA_mal.scala @@ -50,8 +50,8 @@ object stepA_mal { var ast = orig_ast; var env = orig_env; while (true) { - if (env.find(Symbol("DEBUG-EVAL"))) { - dbgeval = env.get(Symbol("DEBUG-EVAL")) + if (env.find(Symbol("DEBUG-EVAL")) != null) { + val dbgeval = env.get(Symbol("DEBUG-EVAL")) if (dbgeval != null && dbgeval != false) { println("EVAL: " + printer._pr_str(ast,true)) } @@ -144,16 +144,16 @@ object stepA_mal { if (fn.ismacro) { ast = fn(rest) // continue loop (TCO) } else { - el = rest.map(EVAL(_, env)) + val el = rest.map(EVAL(_, env)) env = fn.gen_env(el) ast = fn.ast // continue loop (TCO) } } case fn: Func => { - el = rest.map(EVAL(_, env)) + val el = rest.map(EVAL(_, env)) return fn(el) } - case _ => { + case f => { throw new Exception("attempt to call non-function: " + f) } }