diff options
Diffstat (limited to 'php/step9_interop.php')
| -rw-r--r-- | php/step9_interop.php | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/php/step9_interop.php b/php/step9_interop.php index f35244c..d4a59c7 100644 --- a/php/step9_interop.php +++ b/php/step9_interop.php @@ -94,11 +94,14 @@ function MAL_EVAL($ast, $env) { for ($i=0; $i < count($a1); $i+=2) { $let_env->set($a1[$i]->value, MAL_EVAL($a1[$i+1], $let_env)); } - return MAL_EVAL($ast[2], $let_env); + $ast = $ast[2]; + $env = $let_env; + break; // Continue loop (TCO) case "quote": return $ast[1]; case "quasiquote": - return MAL_EVAL(quasiquote($ast[1]), $env); + $ast = quasiquote($ast[1]); + break; // Continue loop (TCO) case "defmacro!": $func = MAL_EVAL($ast[2], $env); $func->ismacro = true; @@ -110,7 +113,7 @@ function MAL_EVAL($ast, $env) { case "do": eval_ast($ast->slice(1, -1), $env); $ast = $ast[count($ast)-1]; - break; + break; // Continue loop (TCO) case "if": $cond = MAL_EVAL($ast[1], $env); if ($cond === NULL || $cond === false) { @@ -119,7 +122,7 @@ function MAL_EVAL($ast, $env) { } else { $ast = $ast[2]; } - break; + break; // Continue loop (TCO) case "fn*": return _function('MAL_EVAL', 'native', $ast[2], $env, $ast[1]); @@ -130,6 +133,7 @@ function MAL_EVAL($ast, $env) { if ($f->type === 'native') { $ast = $f->ast; $env = $f->gen_env($args); + // Continue loop (TCO) } else { return $f->apply($args); } |
