Be smarter about capturing the environment for memoized code
authorAndy Wingo <wingo@pobox.com>
Thu, 31 Oct 2013 21:16:10 +0000 (22:16 +0100)
committerAndy Wingo <wingo@pobox.com>
Thu, 31 Oct 2013 21:16:10 +0000 (22:16 +0100)
commitef47c4229c9c19db56bb0c123eba01c71c4a2011
tree4e07c00197b07df63824f4e4a83875929a74a144
parent3e248c70e3be268b6ad71c9eee9895519ab0495f
Be smarter about capturing the environment for memoized code

* libguile/memoize.h (SCM_M_CAPTURE_MODULE)
* libguile/memoize.c (MAKMEMO_CAPTURE_MODULE, capture_env):
  (maybe_makmemo_capture_module, memoize): Determine when to capture the
  module on the environment chain at compile-time, instead of at
  runtime.  Introduces a new memoized expression type, capture-module.
  (scm_memoized_expression): Start memoizing with #f as the
  environment.
  (unmemoize): Add unmemoizer.
  (scm_memoize_variable_access_x): Cope with #f as module, and treat as
  the root module (captured before modules were booted).

* libguile/eval.c (eval):
* module/ice-9/eval.scm (primitive-eval): Adapt.
libguile/eval.c
libguile/memoize.c
libguile/memoize.h
module/ice-9/eval.scm