diff options
author | Andy Wingo <wingo@pobox.com> | 2013-10-26 13:10:43 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2013-10-26 13:10:43 +0200 |
commit | 27ecfd3649dc6fbc5f512d3e95a8b8ac2139e2b9 (patch) | |
tree | 6b1e8d894f2b656842912e15bf614ba3ab525a1f /libguile/memoize.c | |
parent | cfc28c808e44582e9751b54713c58fd91ab53f16 (diff) | |
download | guile-27ecfd3649dc6fbc5f512d3e95a8b8ac2139e2b9.tar.gz |
Evaluator sets same procedure properties as compiler
* libguile/memoize.c (MAKMEMO_LAMBDA, memoize): Instead of passing the
docstring in the memoized lambda, pass the meta as-is. That way we
get all procedure properties, including "name".
* module/ice-9/eval.scm (primitive-eval): Set procedure properties when
making lambdas. Don't set the name when defining toplevel variables
-- before we did so only if the procedure didn't have a name
property, but I would like to avoid calls to procedure-property in
eval, because getting the name for an RTL function requires loading up
other modules.
Diffstat (limited to 'libguile/memoize.c')
-rw-r--r-- | libguile/memoize.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/libguile/memoize.c b/libguile/memoize.c index f54feb0ec..10e193c63 100644 --- a/libguile/memoize.c +++ b/libguile/memoize.c @@ -122,9 +122,9 @@ scm_t_bits scm_tc16_memoized; #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, docstring) \ +#define MAKMEMO_LAMBDA(body, arity, meta) \ MAKMEMO (SCM_M_LAMBDA, \ - scm_cons (body, scm_cons (docstring, arity))) + scm_cons (body, scm_cons (meta, arity))) #define MAKMEMO_LET(inits, body) \ MAKMEMO (SCM_M_LET, scm_cons (inits, body)) #define MAKMEMO_QUOTE(exp) \ @@ -367,10 +367,9 @@ memoize (SCM exp, SCM env) case SCM_EXPANDED_LAMBDA: /* The body will be a lambda-case or #f. */ { - SCM meta, docstring, body, proc; + SCM meta, body, proc; meta = REF (exp, LAMBDA, META); - docstring = scm_assoc_ref (meta, scm_sym_documentation); body = REF (exp, LAMBDA, BODY); if (scm_is_false (body)) @@ -388,15 +387,12 @@ memoize (SCM exp, SCM env) MAKMEMO_QUOTE (SCM_EOL), MAKMEMO_QUOTE (SCM_BOOL_F))), FIXED_ARITY (0), - SCM_BOOL_F /* docstring */); + meta); else - proc = memoize (body, env); - - if (scm_is_string (docstring)) - { - SCM args = SCM_MEMOIZED_ARGS (proc); - SCM_SETCAR (SCM_CDR (args), docstring); - } + { + proc = memoize (body, env); + SCM_SETCAR (SCM_CDR (SCM_MEMOIZED_ARGS (proc)), meta); + } return proc; } @@ -460,7 +456,7 @@ memoize (SCM exp, SCM env) arity = FULL_ARITY (nreq, rest, nopt, kw, minits, SCM_BOOL_F); return MAKMEMO_LAMBDA (memoize (body, new_env), arity, - SCM_BOOL_F /* docstring */); + SCM_BOOL_F /* meta, filled in later */); } case SCM_EXPANDED_LET: |