marshal

2013-07-20

Use Cases

DONE Marshal List

  (fmarshal:load (fmarshal:dump (list 1 (list 2 3) 4)))
  ;; => (1 (2 3) 4)

DONE Marshal Vector

  (fmarshal:load (fmarshal:dump #(1 #(2 3) 4)))
  ;; => #(1 #(2 3) 4)

  (fmarshal:load (fmarshal:dump (make-array (list 2 2) :initial-element 0)))
  ;; => # #2A((0 0) (0 0))

DONE Marshal Hashmap


  (let ((h (make-hash-table :test 'equal)))
    (setf (gethash "blub" h) t)
    (gethash "blub" (fmarshal:load (fmarshal:dump h))))
  ;; => T

DONE Marshal Object

  (defclass test-object ()
    (test-slot))

  (let ((o (make-instance 'test-object)))
    (setf (slot-value o 'test-slot) "blub")
    (slot-value (fmarshal:load (fmarshal:dump o)) 'test-slot))
  ;; => "blub"

DONE Marshal References

  (defclass test-inherited (test-object)
    (object-slot))

  (let ((o (make-instance 'test-inherited)))
    (setf (slot-value o 'test-slot) "blub")
    (setf (slot-value o 'object-slot) o)
    (let ((loaded-object (fmarshal:load (fmarshal:dump o))))
      (values
       (slot-value loaded-object 'test-slot)
       (eq loaded-object (slot-value loaded-object 'object-slot)))))
  ;; => "blub", T
Author
J?rgen Bickert <juergenbickert@gmail.com>
Maintainer
J?rgen Bickert <juergenbickert@gmail.com>
License
LGPL, BSD-style