[CM] Saving entire state of the intrepreter?
iainduncanlists at gmail.com
Fri Aug 14 14:50:26 PDT 2020
Great, thanks for the tips guys. I will work on that and no doubt have
On Fri, Aug 14, 2020 at 1:34 PM <bil at ccrma.stanford.edu> wrote:
> I think you can mimic cl-store in s7; for example
> it's possible to call for-each on the repl's top let, omit functions
> aren't interesting, and write the others using format with ~W or
> with :readable. In repl.scm the top let is (*repl* 'top-level-let), so
> we started that repl and typed:
> <1> (define (f1 x) (+ x 1))
> <2> (define f2 (let ((y 3))
> (lambda (z)
> (+ y z))))
> Now we can save this to a file via:
> (call-with-output-file "saved-repl.scm"
> (lambda (p)
> (lambda (var&val)
> (unless (eq? (car var&val) 'exit)
> (format p "(define ~S ~W)~%" (car var&val) (cdr var&val))))
> (*repl* 'top-level-let))))
> The file has:
> (define f2 (let ((y 3)) (lambda (z) (+ y z))))
> (define f1 (lambda (x) (+ x 1)))
> This can be used for (almost) anything (I used the top-level-let
> above for simplicity). You can use (*s7* 'file-names) to
> find what files need to be loaded.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Cmdist