Arc Forumnew | comments | leaders | submitlogin
2 points by rain1 2138 days ago | link | parent

I should add: This works because the host lisp is pure: there is no SET! or mutable cells.

If you have mutable cells, write out and read it back in you'd get a clone of the cell - independent of the original. This seems like the wrong behavior.

To make it work with mutable cells seems kind of impossible. I'm not sure. One system I found replaces mutable cells with distributed uniquely identified mailboxes. (termite scheme).



3 points by waterhouse 2120 days ago | link

It's possible to record the fact that some cons cells (or other structures) are identical. The Lisp reader's #n= notation can be used for this, although usually it's only used to print circular lists. Common Lisp's print-circle can be used to demonstrate this:

  * (let ((x (cons 1 2))) (princ (list x x)) nil)
  ((1 . 2) (1 . 2))
  NIL
  * (let ((*print-circle* t)) (let ((x (cons 1 2))) (princ (list x x))) nil)
  (#1=(1 . 2) #1#)
  NIL
Now, if you have a running process, and you want it to seralize a closure (or, generally, an object) that points to a cell that happens to be identical to something else in the process, and you want to read the closure back in and have its pointed-to cell continue to be identical to that other thing... you'll need something more sophisticated. If each object is given some unique id, that would be one approach; that sounds like the mailboxes thing. Another approach would be... say, if the other cell is the 5th element of a list identified with the global name 'blah, then conceivably that could be a good syntax. This might be useful for modules, separate compilation, and/or saving arbitrary process state.

-----

2 points by whitten 2123 days ago | link

Could you elaborate on this or give me pointer what we re it is discussed?

-----

3 points by rain1 2121 days ago | link

what needs explained?

-----