;; define a structure which we want to pass around} (defstruct silly-cons-pair () ((car initarg car reader silly-car) (cdr initarg cdr reader silly-cdr)) constructor (silly-cons car cdr)) ;; invent a number --- this *must* be more than 16 (defconstant *silly-type-id* 18) ;; make a reader (defconstant *the-reader* (make-obj-reader)) ;; define readers and writers for silly-cons ;; note that both these functions *can* side effect, so circular ;; structures and caching can be handled (using tables or similar), also that the ;; particular reader can be changed for the recursive call ;; to the reader (although I do neither here). (defun write-silly-cons (obj ptr rdr) ;; easy really. Just write whats inside. (write-next (silly-car obj) ptr rdr) (write-next (silly-cdr obj) ptr rdr)) (defun read-silly-cons (ptr rdr) ;; read the internals (let* ((a-car (read-next ptr rdr)) (a-cdr (read-next ptr rdr))) ;; construct the appropriate object (silly-cons a-car a-cdr))) ;; add them to the reader structure (add-reader *the-reader* *silly-type-id* read-silly-cons) (add-writer *the-reader* silly-cons-pair *silly-type-id* write-silly-cons) ;; we can add more types later... ;; should make ;; (pvm-send (pvm-whoami) 102 ;; (silly-cons (silly-cons 1 2) ;; (silly-cons 3 4)) ;; *the-reader*) ;; work ok. ;; to receive, (pvm-recv 102 nil *the-reader*)