[CM] Saving entire state of the intrepreter?

Iain Duncan 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
questions later!

iain

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
> that
> aren't interesting, and write the others using format with ~W or
> object->string
> with :readable.  In repl.scm the top let is (*repl* 'top-level-let), so
> say
> we started that repl and typed:
>
> <1> (define (f1 x) (+ x 1))
> f1
> <2> (define f2 (let ((y 3))
>                   (lambda (z)
>                     (+ y z))))
> f2
>
> Now we can save this to a file via:
>
> (call-with-output-file "saved-repl.scm"
>    (lambda (p)
>      (for-each
>        (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...
URL: <https://cm-mail.stanford.edu/pipermail/cmdist/attachments/20200814/26a8bd20/attachment.html>


More information about the Cmdist mailing list