From 70a8db797c242289782d563b0d8a0368d137e7ab Mon Sep 17 00:00:00 2001 From: Tim Vaughan Date: Wed, 21 Jun 2017 12:38:51 +1200 Subject: [PATCH] Buggy implementation of analyze-lambda. --- src/scheme.4th | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/scheme.4th b/src/scheme.4th index 7d9e2c4..425b378 100644 --- a/src/scheme.4th +++ b/src/scheme.4th @@ -1824,6 +1824,44 @@ hide env nil cons cons cons cons ; +: sequential-executor ( env eproc1 eproc2 -- res ) + 2swap 2 2pick 2swap ( env eproc2 env eproc1 ) + evaluate-eproc 2drop + evaluate-eproc +; + +: analyze-sequence ( explist -- eproc ) + nil? if + except-message: ." Tried to analyze empty expression sequence." recoverable-exception throw + then + + 2dup car analyze + 2swap cdr + nil? if + 2drop + else + recurse + ['] sequential-executor + nil cons cons + then +; + +: lambda-executor ( env params bproc -- res ) + 2rot make-procedure + ( Although this is packaged up as a regular compound procedure, + the "body" element contains an _eproc_ to be evaluated in an + environment resulting from extending env with the parameter + bindings. ) +; + +: analyze-lambda ( exp -- eproc ) + 2dup lambda-parameters + 2swap lambda-body analyze-sequence + + ['] lambda-executor primitive-proc-type + nil cons cons cons +; + :noname ( exp --- eproc ) self-evaluating? if @@ -1856,6 +1894,11 @@ hide env exit then + lambda? if + analyze-lambda + exit + then + ; is analyze -- 2.20.1