summaryrefslogtreecommitdiffstats
path: root/jmp.S
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-03-13 06:48:23 -0700
committerKaz Kylheku <kaz@kylheku.com>2019-03-13 06:48:23 -0700
commit7aef72ae4fd0fcbe18acbbd876fed0aaf6bf87ee (patch)
tree33c45ac37bd683030e0c58601a021203b398b52b /jmp.S
parent3388b5baed9b9288ccd4fcd7611f936cb6025469 (diff)
downloadtxr-7aef72ae4fd0fcbe18acbbd876fed0aaf6bf87ee.tar.gz
txr-7aef72ae4fd0fcbe18acbbd876fed0aaf6bf87ee.tar.bz2
txr-7aef72ae4fd0fcbe18acbbd876fed0aaf6bf87ee.zip
lazy conses: support state in car and cdr.
Here we allow application code to take advantage of a trick already used internally. When a lazy cons cell is created, we can temporarily put state information into its car and cdr fields. When these fields are accessed normally, by the car and cdr function, the lazy cons' update function will be invoked, which will populate these fields. If we have a way for that function to retrieve the existing values of those fields, then the function can treat those fields as state information: it can retrieve the values into temporary local variables, overwrite the original values, and then propagate the state information into the car and cdr into the next lazy cons cell being added. Thus lazy list generation that needs two cells of state or less does not require the allocation of a context object. * eval.c (eval_init): make-lazy-cons becomes a three-argument function with two optional parameters. New functions lcons-car and lcons-cdr are registered. * lib.c (make_lazy_cons_pub): New function, wrapping make_lazy_cons_car_cdr with argument defaulting. (lcons_car, lcons_cdr): New functions. * lib.h (make_lazy_cons_pu, lcons_car, lcons_cdr): Declared. * txr.1: Updated doc of make-lazy-cons regarding new arguments. Documented lcons-car and lcons-cdr.
Diffstat (limited to 'jmp.S')
0 files changed, 0 insertions, 0 deletions