From 9dbc686ad7d3289dc0f9bcf4a973f71100e02ded Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 3 Dec 2017 19:54:18 -0800 Subject: altos/lisp: Switch to scheme formal syntax for varargs Scheme uses bare symbols to indicate a varargs parameter; any bare (i.e., not wrapped in a cons cell) parameter will get the 'rest' of the parameter list. This works for lambdas, nlambdas and macros. As a result, the 'lexpr' form has been removed as it is equivalent to a lambda with a varargs formal. Signed-off-by: Keith Packard --- src/lisp/ao_lisp_make_const.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/lisp/ao_lisp_make_const.c') diff --git a/src/lisp/ao_lisp_make_const.c b/src/lisp/ao_lisp_make_const.c index f3ea6be0..6e4b411e 100644 --- a/src/lisp/ao_lisp_make_const.c +++ b/src/lisp/ao_lisp_make_const.c @@ -191,6 +191,7 @@ ao_has_macro(ao_poly p) struct ao_lisp_cons *cons; struct ao_lisp_lambda *lambda; ao_poly m; + ao_poly list; if (p == AO_LISP_NIL) return AO_LISP_NIL; @@ -206,15 +207,16 @@ ao_has_macro(ao_poly p) if ((p = ao_is_macro(cons->car))) break; - cons = ao_lisp_poly_cons(cons->cdr); + list = cons->cdr; p = AO_LISP_NIL; - while (cons) { + while (list != AO_LISP_NIL && ao_lisp_poly_type(list) == AO_LISP_CONS) { + cons = ao_lisp_poly_cons(list); m = ao_has_macro(cons->car); if (m) { p = m; break; } - cons = ao_lisp_poly_cons(cons->cdr); + list = cons->cdr; } break; -- cgit v1.2.3