mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-24 12:20:20 +02:00
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.
This commit is contained in:
parent
fb6e61ca21
commit
826373a25d
4 changed files with 3316 additions and 3180 deletions
|
@ -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,12 +1049,24 @@ 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)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue