Arc Forumnew | comments | leaders | submitlogin
3 points by waterhouse 10 days ago | link | parent

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.