summaryrefslogtreecommitdiff
path: root/libguile/memoize.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2010-05-20 12:53:21 +0200
committerAndy Wingo <wingo@pobox.com>2010-05-20 12:53:21 +0200
commit632ddbf02b6983a93a3a8f1268772b78354a335a (patch)
tree3fa0523df57b4f908059dbe1124b297ec74f93c0 /libguile/memoize.c
parenta310a1d12e9b44ba77bb28d5491f0bd378a90886 (diff)
downloadguile-632ddbf02b6983a93a3a8f1268772b78354a335a.tar.gz
iron out inconsistency between eval and compile expansion
* libguile/expand.c (expand_lambda_star_case): Harmonize with tree-il, expanding keywords to (aok? (kw name gensym) ...), not (aok? (kw . index) ...). * libguile/memoize.c (memoize): Process the (kw name gensym) format into (kw . index). * module/ice-9/psyntax.scm (build-lambda-case): Remove a compile-versus-eval special case. * module/ice-9/psyntax-pp.scm: Regenerate.
Diffstat (limited to 'libguile/memoize.c')
-rw-r--r--libguile/memoize.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/libguile/memoize.c b/libguile/memoize.c
index 2604be9ea..393598e94 100644
--- a/libguile/memoize.c
+++ b/libguile/memoize.c
@@ -273,7 +273,7 @@ memoize (SCM exp, SCM env)
{
SCM req, rest, opt, kw, inits, vars, body, alt;
SCM walk, minits, arity, new_env;
- int nreq, nopt;
+ int nreq, nopt, ntotal;
req = REF (exp, LAMBDA_CASE, REQ);
rest = REF (exp, LAMBDA_CASE, REST);
@@ -286,6 +286,7 @@ memoize (SCM exp, SCM env)
nreq = scm_ilength (req);
nopt = scm_is_pair (opt) ? scm_ilength (opt) : 0;
+ ntotal = scm_ilength (vars);
/* The vars are the gensyms, according to the divine plan. But we need
to memoize the inits within their appropriate environment,
@@ -319,6 +320,22 @@ memoize (SCM exp, SCM env)
minits = scm_reverse_x (minits, SCM_UNDEFINED);
+ if (scm_is_true (kw))
+ {
+ /* (aok? (kw name sym) ...) -> (aok? (kw . index) ...) */
+ SCM aok = CAR (kw), indices = SCM_EOL;
+ for (kw = CDR (kw); scm_is_pair (kw); kw = CDR (kw))
+ {
+ SCM k;
+ int idx;
+
+ k = CAR (CAR (kw));
+ idx = ntotal - 1 - lookup (CADDR (CAR (kw)), new_env);
+ indices = scm_acons (k, SCM_I_MAKINUM (idx), indices);
+ }
+ kw = scm_cons (aok, scm_reverse_x (indices, SCM_UNDEFINED));
+ }
+
if (scm_is_false (alt) && scm_is_false (kw) && scm_is_false (opt))
{
if (scm_is_false (rest))