diff options
| author | Keith Packard <keithp@keithp.com> | 2016-11-15 09:55:22 -0800 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2017-02-20 11:16:51 -0800 | 
| commit | 974717eb9dad105c9897ee24f953d98d57eaec77 (patch) | |
| tree | ea77eec1b39f859353f17ad384950f6bd982c569 /src/lisp/ao_lisp_const.lisp | |
| parent | b3b5bd2c14cfcde6c551a87ee6da08a53f1e4bc6 (diff) | |
altos/lisp: Evaluate macros once, then smash them into place
This assumes that macros are all pure functions, which should be true
for syntactic macros.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/lisp/ao_lisp_const.lisp')
| -rw-r--r-- | src/lisp/ao_lisp_const.lisp | 24 | 
1 files changed, 13 insertions, 11 deletions
| diff --git a/src/lisp/ao_lisp_const.lisp b/src/lisp/ao_lisp_const.lisp index c6f50e34..9d8af588 100644 --- a/src/lisp/ao_lisp_const.lisp +++ b/src/lisp/ao_lisp_const.lisp @@ -9,10 +9,6 @@  ;(setq progn (lexpr (l) (last l))) -					; simple math operators - -(setq 1+ (lambda (x) (+ x 1))) -(setq 1- (lambda (x) (- x 1)))  					;  					; Define a variable without returning the value @@ -64,7 +60,7 @@  					; make the list of names in the let  					; -		     (set 'make-names (lambda (vars) +		     (setq make-names (lambda (vars)  				       (cond (vars  					      (cons (car (car vars))  						    (make-names (cdr vars)))) @@ -77,7 +73,7 @@  					; pre-pended to the  					; expressions to evaluate  					; -		     (set 'make-exprs (lambda (vars exprs) +		     (setq make-exprs (lambda (vars exprs)  				       (progn  					 (cond (vars (cons  						      (list set @@ -94,13 +90,13 @@  					 )  				       )  			  ) -		     (set 'exprs (make-exprs vars exprs)) +		     (setq exprs (make-exprs vars exprs))  					;  					; the parameters to the lambda is a list  					; of nils of the right length  					; -		     (set 'make-nils (lambda (vars) +		     (setq make-nils (lambda (vars)  				      (cond (vars (cons nil (make-nils (cdr vars))))  					    )  				      ) @@ -108,7 +104,6 @@  					;  					; build the lambda.  					; -		     (set 'last-let-value   		     (cons  		      (list  		       'lambda @@ -120,8 +115,6 @@  		      (make-nils vars)  		      )  		     ) -		     ) -		       		   )  		 (car let-param)  		 (cdr let-param) @@ -158,3 +151,12 @@  		      )  		    )       ) + +					; simple math operators +					; +					; Do these last to run defun +					; at least once so the let macro +					; is resolved + +(defun 1+ (x) (+ x 1)) +(defun 1- (x) (- x 1)) | 
