Arc Forumnew | comments | leaders | submitlogin
Restart Points in arc/lisp
1 point by lboard 5893 days ago | 4 comments
Is there a way to specify restart points similar to dbms transactions in arc/lisp.

So that it can be used in programs like a server. Before starting a server the restart point is set and when any error occurs in server and goes down, the program can be triggered back to start from the restart point.

Implementation may be like the whole interpreter environemnt may be saved to a file and loaded back.



2 points by almkglor 5892 days ago | link

@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 5891 days ago | link

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

-----

3 points by drcode 5893 days ago | link

Take a look at my nondeterministic regular expression library to see how you can do this.

Or, read "On Lisp" to learn how to do this with continuations, as stefano already pointed out.

-----

3 points by stefano 5893 days ago | link

You could use continuations to implement it.

-----