create-symbol if if-symbol
create-symbol lambda lambda-symbol
create-symbol λ λ-symbol
+create-symbol begin begin-symbol
\ }}}
drop compound-proc-type
;
+: begin? ( obj -- obj bool )
+ begin-symbol tagged-list? ;
+
+: begin-actions ( obj -- actions )
+ cdr ;
+
+: eval-sequence ( explist env -- finalexp env )
+ ( Evaluates all bar the final expressions in
+ an an expression list. The final expression
+ is returned to allow for tail optimization. )
+
+ 2swap ( env explist )
+
+ \ Abort on empty list
+ 2dup nil objeq? if 2swap exit then
+
+ begin
+ 2dup cdr ( env explist nextexplist )
+ 2dup nil objeq? false =
+ while
+ -2rot car 2over ( nextexplist env exp env )
+ eval
+ 2drop \ discard result
+ 2swap ( env nextexplist )
+ repeat
+
+ 2drop car 2swap ( finalexp env )
+;
+
: application? ( obj -- obj bool)
pair-type istype? ;
extend-env ( body env )
- 2swap ( env body )
-
- begin
- 2dup cdr 2dup nil objeq? false =
- while
- -2rot car 2over ( nextbody env exp env )
- eval
- 2drop \ discard result
- 2swap ( env nextbody )
- repeat
-
- 2drop ( env body )
- car 2swap ( exp env )
+ eval-sequence
R> drop ['] eval goto-deferred \ Tail call optimization
endof
exit
then
+ begin? if
+ \ TODO
+ then
+
application? if
2over 2over
operator 2swap eval