altos/lisp: Add scheme-style bools (#t and #f)
[fw/altos] / src / lisp / ao_lisp_lambda.c
index 656936cb88c691b10077b5543fb2693d56dfbe34..cc333d6fc3a0dcc8252f8241fd4d21158da142f1 100644 (file)
@@ -15,7 +15,6 @@
  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  */
 
-#define DBG_EVAL 0
 #include "ao_lisp.h"
 
 int
@@ -78,9 +77,6 @@ ao_lisp_lambda_alloc(struct ao_lisp_cons *code, int args)
        if (!lambda)
                return AO_LISP_NIL;
 
-       if (!code->cdr)
-               return ao_lisp_error(AO_LISP_INVALID, "missing parameters to lambda");
-
        if (!ao_lisp_check_argt(_ao_lisp_atom_lambda, code, 0, AO_LISP_CONS, 1))
                return AO_LISP_NIL;
        f = 0;
@@ -102,25 +98,25 @@ ao_lisp_lambda_alloc(struct ao_lisp_cons *code, int args)
 }
 
 ao_poly
-ao_lisp_lambda(struct ao_lisp_cons *cons)
+ao_lisp_do_lambda(struct ao_lisp_cons *cons)
 {
        return ao_lisp_lambda_alloc(cons, AO_LISP_FUNC_LAMBDA);
 }
 
 ao_poly
-ao_lisp_lexpr(struct ao_lisp_cons *cons)
+ao_lisp_do_lexpr(struct ao_lisp_cons *cons)
 {
        return ao_lisp_lambda_alloc(cons, AO_LISP_FUNC_LEXPR);
 }
 
 ao_poly
-ao_lisp_nlambda(struct ao_lisp_cons *cons)
+ao_lisp_do_nlambda(struct ao_lisp_cons *cons)
 {
        return ao_lisp_lambda_alloc(cons, AO_LISP_FUNC_NLAMBDA);
 }
 
 ao_poly
-ao_lisp_macro(struct ao_lisp_cons *cons)
+ao_lisp_do_macro(struct ao_lisp_cons *cons)
 {
        return ao_lisp_lambda_alloc(cons, AO_LISP_FUNC_MACRO);
 }
@@ -170,8 +166,7 @@ ao_lisp_lambda_eval(void)
        case AO_LISP_FUNC_LAMBDA:
                for (f = 0; f < args_wanted; f++) {
                        DBGI("bind "); DBG_POLY(args->car); DBG(" = "); DBG_POLY(vals->car); DBG("\n");
-                       next_frame->vals[f].atom = args->car;
-                       next_frame->vals[f].val = vals->car;
+                       ao_lisp_frame_bind(next_frame, f, args->car, vals->car);
                        args = ao_lisp_poly_cons(args->cdr);
                        vals = ao_lisp_poly_cons(vals->cdr);
                }
@@ -184,14 +179,12 @@ ao_lisp_lambda_eval(void)
        case AO_LISP_FUNC_MACRO:
                for (f = 0; f < args_wanted - 1; f++) {
                        DBGI("bind "); DBG_POLY(args->car); DBG(" = "); DBG_POLY(vals->car); DBG("\n");
-                       next_frame->vals[f].atom = args->car;
-                       next_frame->vals[f].val = vals->car;
+                       ao_lisp_frame_bind(next_frame, f, args->car, vals->car);
                        args = ao_lisp_poly_cons(args->cdr);
                        vals = ao_lisp_poly_cons(vals->cdr);
                }
                DBGI("bind "); DBG_POLY(args->car); DBG(" = "); DBG_POLY(ao_lisp_cons_poly(vals)); DBG("\n");
-               next_frame->vals[f].atom = args->car;
-               next_frame->vals[f].val = ao_lisp_cons_poly(vals);
+               ao_lisp_frame_bind(next_frame, f, args->car, ao_lisp_cons_poly(vals));
                break;
        default:
                break;