altos/lisp: Evaluate macros once, then smash them into place
[fw/altos] / src / lisp / ao_lisp_const.lisp
index c6f50e346c9dd8bb61fcbc12eee7c6525af1ea23..9d8af58862e1af43a7fb1c21fe005999cf56178a 100644 (file)
@@ -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)
+                    (setmake-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)
+                    (setmake-exprs (lambda (vars exprs)
                                       (progn
                                         (cond (vars (cons
                                                      (list set
                                         )
                                       )
                          )
-                    (set 'exprs (make-exprs vars exprs))
+                    (setexprs (make-exprs vars exprs))
 
                                        ;
                                        ; the parameters to the lambda is a list
                                        ; of nils of the right length
                                        ;
-                    (set 'make-nils (lambda (vars)
+                    (setmake-nils (lambda (vars)
                                      (cond (vars (cons nil (make-nils (cdr vars))))
                                            )
                                      )
                                        ;
                                        ; build the lambda.
                                        ;
-                    (set 'last-let-value 
                     (cons
                      (list
                       'lambda
                      (make-nils vars)
                      )
                     )
-                    )
-                    
                   )
                 (car let-param)
                 (cdr let-param)
                      )
                    )
      )
+
+                                       ; 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))