diff options
author | Andy Wingo <wingo@pobox.com> | 2010-05-13 16:56:31 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2010-05-13 23:37:15 +0200 |
commit | 9658182d5f51368e2888cb461edfc2f35f91c6ac (patch) | |
tree | 76f905a940575ba794b6eb00fce81efeef3e28e0 /libguile/memoize.c | |
parent | 8f9c5b589d7552d79cbafda3029986b714807a25 (diff) | |
download | guile-9658182d5f51368e2888cb461edfc2f35f91c6ac.tar.gz |
tweak to lambda* memoization format
* libguile/memoize.c (FULL_ARITY): Change the form to more closely
approximate <lambda-case>.
(unmemoize): Unmemoize lambda* expressions.
Diffstat (limited to 'libguile/memoize.c')
-rw-r--r-- | libguile/memoize.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/libguile/memoize.c b/libguile/memoize.c index 87375f790..2cfb0cb00 100644 --- a/libguile/memoize.c +++ b/libguile/memoize.c @@ -183,9 +183,9 @@ scm_t_bits scm_tc16_memoized; scm_list_1 (SCM_I_MAKINUM (nreq)) #define REST_ARITY(nreq, rest) \ scm_list_2 (SCM_I_MAKINUM (nreq), rest) -/* opts := #f | (aok? (pos? kw init) ...) */ -#define FULL_ARITY(nreq, rest, opts, alt) \ - scm_list_4 (SCM_I_MAKINUM (nreq), rest, opts, alt) +#define FULL_ARITY(nreq, rest, nopt, kw, inits, alt) \ + scm_list_n (SCM_I_MAKINUM (nreq), rest, SCM_I_MAKINUM (nopt), kw, inits, \ + alt, SCM_UNDEFINED) #define MAKMEMO_LAMBDA(body, arity) \ MAKMEMO (SCM_M_LAMBDA, (scm_cons (body, arity))) #define MAKMEMO_LET(inits, body) \ @@ -1349,7 +1349,21 @@ unmemoize (const SCM expr) unmemoize (CAR (args))); } else - abort (); + { + SCM body = CAR (args), spec = CDR (args), alt; + + alt = CADDR (CDDDR (spec)); + if (scm_is_true (alt)) + abort (); + + return scm_list_3 (sym_lambda_star, + scm_list_5 (CAR (spec), + CADR (spec), + CADDR (spec), + CADDDR (spec), + unmemoize_exprs (CADR (CDDDR (spec)))), + unmemoize (body)); + } case SCM_M_LET: return scm_list_3 (scm_sym_let, unmemoize_bindings (CAR (args)), |