diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2018-11-13 21:19:45 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2018-11-13 21:19:45 -0800 |
commit | bfc527af1af619742163d238eac9f2b24f363b0d (patch) | |
tree | 9922d8e4392d3ce95851edb1f0073ed52913f114 /stream.h | |
parent | 8e2aef8f2b466b37753ba0acd4bd668ff54b3669 (diff) | |
download | txr-bfc527af1af619742163d238eac9f2b24f363b0d.tar.gz txr-bfc527af1af619742163d238eac9f2b24f363b0d.tar.bz2 txr-bfc527af1af619742163d238eac9f2b24f363b0d.zip |
compile: handle functions that have environments.
With this patch, the compile function can handle interpreted
function objects that have captured environments.
For instance, if the following expression is evaluated
(let ((counter 0))
(labels ((bm () (bump))
(bump () (inc counter)))
(lambda () (bm))))
then a function object emerges. We can now feed this
function object to the compile function; the environment
will now be handled.
Of course, the above expression is already compileable;
compile-toplevel handles it and so does the file compiler.
This patch allows the expression to be interpreted and then
the function object to be compiled, without access to the
surrounding expression. The compiled function will contain a
compiled version of the environment, carrying compiled
versions of the captured variables and their contents.
* eval.c (env_vbindings, env_fbindings, env_next): New static
functions.
(eval_init): Register env-vbinding, env-fbindings and env-next
intrinsics.
* share/txr/stdlib/compiler.tl (sys:env-to-let): New function.
(usr:compile): Wrap the interpreted lambda terms with let
bindings carefully reconstructed from their captured
environments.
* txr.1: Documented new intrinsic functions.
Diffstat (limited to 'stream.h')
0 files changed, 0 insertions, 0 deletions