mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 03:30:27 +02:00
scm_memoize_lambda update
* libguile/memoize.h: * libguile/memoize.c (scm_memoize_lambda): Update to memoize "full-arity" lambdas.
This commit is contained in:
parent
12922f0dd1
commit
311fbeb7c3
2 changed files with 24 additions and 6 deletions
|
@ -1378,13 +1378,30 @@ SCM_DEFINE (scm_memoize_if, "memoize-if", 3, 0, 0,
|
|||
}
|
||||
#undef FUNC_NAME
|
||||
|
||||
SCM_DEFINE (scm_memoize_lambda, "memoize-lambda", 3, 0, 0,
|
||||
(SCM nreq, SCM rest, SCM body), "")
|
||||
SCM_DEFINE (scm_memoize_lambda, "memoize-lambda", 3, 4, 0,
|
||||
(SCM body, SCM nreq, SCM rest, SCM nopt, SCM kw, SCM inits, SCM alt), "")
|
||||
#define FUNC_NAME s_scm_memoize_lambda
|
||||
{
|
||||
SCM_VALIDATE_BOOL (2, rest);
|
||||
SCM_VALIDATE_MEMOIZED (3, body);
|
||||
return MAKMEMO_LAMBDA (body, REST_ARITY (scm_to_uint16 (nreq), rest));
|
||||
SCM_VALIDATE_MEMOIZED (1, body);
|
||||
if (SCM_UNBNDP (nopt))
|
||||
{
|
||||
if (scm_is_true (rest))
|
||||
return MAKMEMO_LAMBDA (body, FIXED_ARITY (scm_to_uint16 (nreq)));
|
||||
else
|
||||
MAKMEMO_LAMBDA (body, REST_ARITY (scm_to_uint16 (nreq), rest));
|
||||
}
|
||||
if (SCM_UNBNDP (kw))
|
||||
kw = SCM_BOOL_F;
|
||||
if (SCM_UNBNDP (inits))
|
||||
inits = SCM_EOL;
|
||||
if (SCM_UNBNDP (alt))
|
||||
alt = SCM_BOOL_F;
|
||||
else
|
||||
SCM_VALIDATE_MEMOIZED (7, alt);
|
||||
return MAKMEMO_LAMBDA (body,
|
||||
FULL_ARITY (scm_to_uint16 (nreq), rest,
|
||||
scm_to_uint16 (nopt), kw, inits, alt));
|
||||
|
||||
}
|
||||
#undef FUNC_NAME
|
||||
|
||||
|
|
|
@ -109,7 +109,8 @@ SCM_INTERNAL SCM scm_memoizer (SCM obj);
|
|||
|
||||
SCM_INTERNAL SCM scm_memoize_begin (SCM exps);
|
||||
SCM_INTERNAL SCM scm_memoize_if (SCM test, SCM then, SCM else_);
|
||||
SCM_INTERNAL SCM scm_memoize_lambda (SCM nreq, SCM rest, SCM body);
|
||||
SCM_INTERNAL SCM scm_memoize_lambda (SCM body, SCM nreq, SCM rest, SCM nopt,
|
||||
SCM kw, SCM inits, SCM alt);
|
||||
SCM_INTERNAL SCM scm_memoize_let (SCM inits, SCM body);
|
||||
SCM_INTERNAL SCM scm_memoize_quote (SCM exp);
|
||||
SCM_INTERNAL SCM scm_memoize_define (SCM var, SCM val);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue