aboutsummaryrefslogtreecommitdiff
path: root/perl/stepA_more.pl
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-04-23 21:59:50 -0500
committerJoel Martin <github@martintribe.org>2014-04-23 21:59:50 -0500
commit6301e0b6374cecc5599665be14d6ddc6a31ce1e8 (patch)
treedbf1dc2ff6c682fd87c72a7907e7f6e59c8d4c03 /perl/stepA_more.pl
parent89bd4de1e2704c1bc562788b2c5e4fc08b71a538 (diff)
downloadmal-6301e0b6374cecc5599665be14d6ddc6a31ce1e8.tar.gz
mal-6301e0b6374cecc5599665be14d6ddc6a31ce1e8.zip
All: TCO let* and quasiquote.
Diffstat (limited to 'perl/stepA_more.pl')
-rw-r--r--perl/stepA_more.pl7
1 files changed, 6 insertions, 1 deletions
diff --git a/perl/stepA_more.pl b/perl/stepA_more.pl
index 8520480..eca2b6e 100644
--- a/perl/stepA_more.pl
+++ b/perl/stepA_more.pl
@@ -118,12 +118,14 @@ sub EVAL {
}
$ast = $a2;
$env = $let_env;
+ # Continue loop (TCO)
}
when (/^quote$/) {
return $a1;
}
when (/^quasiquote$/) {
- return EVAL(quasiquote($a1), $env);
+ $ast = quasiquote($a1);
+ # Continue loop (TCO)
}
when (/^defmacro!$/) {
my $func = EVAL($a2, $env);
@@ -166,6 +168,7 @@ sub EVAL {
when (/^do$/) {
eval_ast($ast->slice(1, $#{$ast->{val}}-1), $env);
$ast = $ast->nth($#{$ast->{val}});
+ # Continue loop (TCO)
}
when (/^if$/) {
my $cond = EVAL($a1, $env);
@@ -174,6 +177,7 @@ sub EVAL {
} else {
$ast = $a2;
}
+ # Continue loop (TCO)
}
when (/^fn\*$/) {
return Function->new(\&EVAL, $a2, $env, $a1);
@@ -184,6 +188,7 @@ sub EVAL {
if ((ref $f) =~ /^Function/) {
$ast = $f->{ast};
$env = $f->gen_env($el->rest());
+ # Continue loop (TCO)
} else {
return &{ $f }($el->rest());
}