Arc Forumnew | comments | leaders | submitlogin
2 points by almkglor 5879 days ago | link | parent

@drcode & stefano: I somehow doubt that "whole interpreter environment may be saved to a file and loaded back" can be implemented with continuations.

Well, maybe, but we'd probably need 1) destructurable functions (so we can serialize functions), 2) some way of iterating over global variables, 3) a decent sense of 'eq?, one which returns false for distinct mutable strings, preferably in an easy eq?-key-compare association table (so we can properly/easily serialize recursive structures).

Arc-on-mzscheme actually maintains a table of globals that have been ever assigned, together with the last known arc-side assignment (IIRC it actually keeps two copies of the global, one in the table and one in the actual mzscheme global variable space).

edit:

@lboard: I also somehow doubt you want to save the whole interpreter environment; probably you just want something like this:

  (mac restartable body
    `(*restartable-f (fn (restart) ,@body)))
  (def *restartable-f (bf)
    (bf (point ret (afn () (ret self)))))
Usage:

  (restartable
    (initialize-me)
    (while foo
      (if
        (some-event)
          (do-something)
        (some-error-occured)
          (restart))))
Note that 'restart is a local above, so if you need to use functions:

  (def my-do-something (restart)
    (if
      (some-event)
        (do-something)
      (some-error-occured)
        (restart)))

  (restartable
    (initialize-me)
    (while foo
      (my-do-something restart)))
This is the "continuation" solution that stefano and drcode are referring to; in general you probably want this, not necessarily saving the whole interpreter state.


1 point by drcode 5878 days ago | link

you're right- I may not have thought about some of the details involved in this.

-----