summaryrefslogtreecommitdiff
path: root/libguile/expand.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2010-06-17 11:12:58 +0200
committerAndy Wingo <wingo@pobox.com>2010-06-17 13:43:26 +0200
commit826373a25d71173f0f5045c61dc5854910cf1a80 (patch)
treea851907357f7b01926a42b3c97d2744a8571915b /libguile/expand.c
parentfb6e61ca21b397308474a6a553f7d502d0113251 (diff)
downloadguile-826373a25d71173f0f5045c61dc5854910cf1a80.tar.gz
psyntax, primitive expander, and memoizer support for letrec*
* libguile/expand.c (expand_letrec_helper): Factor out common code. (expand_letrec): Use expand_letrec_helper. (expand_letrec_star): New primitive syntax: letrec*. * libguile/memoize.c (memoize): Add memoizer support for in-order letrec (letrec*). * module/ice-9/psyntax.scm (build-letrec): Another arg, `in-order?'. (chi-body): Adapt to build-letrec change. We don't yet use letrec* for internal definitions. (letrec): Adapt to build-letrec change. (letrec*): New expander. * module/ice-9/psyntax-pp.scm: Regenerated.
Diffstat (limited to 'libguile/expand.c')
-rw-r--r--libguile/expand.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/libguile/expand.c b/libguile/expand.c
index 62e3acfb6..bdecd80d8 100644
--- a/libguile/expand.c
+++ b/libguile/expand.c
@@ -163,6 +163,7 @@ SCM_SYNTAX ("set!", expand_set_x);
SCM_SYNTAX ("and", expand_and);
SCM_SYNTAX ("cond", expand_cond);
SCM_SYNTAX ("letrec", expand_letrec);
+SCM_SYNTAX ("letrec*", expand_letrec_star);
SCM_SYNTAX ("let*", expand_letstar);
SCM_SYNTAX ("or", expand_or);
SCM_SYNTAX ("lambda*", expand_lambda_star);
@@ -1030,7 +1031,7 @@ expand_let (SCM expr, SCM env)
}
static SCM
-expand_letrec (SCM expr, SCM env)
+expand_letrec_helper (SCM expr, SCM env, SCM in_order_p)
{
SCM bindings;
@@ -1048,13 +1049,25 @@ expand_letrec (SCM expr, SCM env)
SCM var_names, var_syms, inits;
transform_bindings (bindings, expr, &var_names, &var_syms, &inits);
env = expand_env_extend (env, var_names, var_syms);
- return LETREC (SCM_BOOL_F, SCM_BOOL_F,
+ return LETREC (SCM_BOOL_F, in_order_p,
var_names, var_syms, expand_exprs (inits, env),
expand_sequence (CDDR (expr), env));
}
}
static SCM
+expand_letrec (SCM expr, SCM env)
+{
+ return expand_letrec_helper (expr, env, SCM_BOOL_F);
+}
+
+static SCM
+expand_letrec_star (SCM expr, SCM env)
+{
+ return expand_letrec_helper (expr, env, SCM_BOOL_T);
+}
+
+static SCM
expand_letstar_clause (SCM bindings, SCM body, SCM env SCM_UNUSED)
{
if (scm_is_null (bindings))