Anonymous user
Object serialization: Difference between revisions
m
Fixed self-reference bug. EchoLisp 2.11
m (Added self-referencing note to EchoLisp) |
m (Fixed self-reference bug. EchoLisp 2.11) |
||
Line 705:
=={{header|EchoLisp}}==
Our classes will be 'struct' objects, with custom #:tostring procedures, as required. The instances are saved/restored to/from local storage. Serialization is performed by JSONifying the objects. References between instances of struct's are kept in the process. Auto-references and circular references are correctly maintained since EchoLisp version 2.11.
<lang lisp>
(define (person->string self) (format "%a : person." (person-name self)))
Line 727:
(local-put-value 'simon simon "objects.dat")
📕 local-db: local-put:unknown store : "objects.dat"
;; forgot to create the
(local-make-store "objects.dat") → "objects.dat"
Line 742:
<lang lisp>
;; reboot (close the browser window)
; inspect objects.dat :
(local-keys 'objects.dat) → ("elvis" "papa" "simon")
Line 759 ⟶ 760:
papa → papa: father of (Antoinette Elvis). ; YES 😳 !
;;
;; add 'papa' to the chidren of 'papa' - whatever this means - and print it :
(set-father-children! papa (list simon papa elvis))
papa → papa: father of (Antoinette papa Elvis).
; save/restore
(local-put-value 'papa papa "objects.dat")
(define papa (local-get-value 'papa "objects.dat"))
papa → papa: father of (Antoinette papa Elvis).
</lang>
|