+: operand-eproc-list ( operands -- eprocs )
+ nil? invert if
+ 2dup car analyze
+ 2swap cdr recurse
+ cons
+ then
+;
+
+: evaluate-operand-eprocs ( env aprocs -- vals )
+ nil? invert if
+ 2over 2over car evaluate-eproc ( env aprocs thisres )
+ -rot cdr recurse
+;
+
+: application-executor ( operator-proc arg-procs env -- res )
+ 2rot 2over ( aprocs env fproc env )
+ evaluate-eproc ( aprocs env proc )
+ 2swap -2rot 2over 2swap ( proc env env aprocs )
+ evaluate-operand-eprocs ( proc env vals )
+
+ 2rot ( env vals proc )
+
+ dup case
+ primitive-proc-type of
+ 2rot 2drop execute
+ endof
+
+ compound-proc-type of
+ 2dup procedure-body ( argvals proc body )
+ -2rot 2dup procedure-params ( bproc argvals proc argnames )
+ -2rot procedure-env ( bproc argnames argvals procenv )
+
+ -2rot 2swap
+ flatten-proc-args
+ 2swap 2rot
+
+ extend-env ( bproc env )
+
+ ['] evaluate-eproc goto
+ endof
+
+ except-message: ." object '" drop print ." ' not applicable." recoverable-exception throw
+ endcase
+;
+
+: analyze-application ( exp -- eproc )
+ 2dup operator analyze
+ 2swap operands operand-eproc-list
+
+ ['] application-executor
+ nil cons cons cons
+;
+