3 ms·
Educate me, because I think I've found an outright error in the linked page: > In Tcl serialization just happens for many types because almost everything has a
by derleth 16y ago
Educate me, because I think I've found an outright error in the linked page:
> In Tcl serialization just happens for many types because almost everything has a string representation. You can write a Tcl list in a file just with: puts $fd $list. This is not possible in Lisp, where you need to perform serialization.
This is, from what I can see, wrong: In Lisp, you have the write function, which can 'serialize' arbitrarily complex data structures in a form acceptable to the read function. That's pretty much it, unless you're trying to do something odd like applying write to a compiled function or some other implementation-specific bizarre internal data structure that doesn't have a write-able representation.
Therefore, the linked page seems to be missing or mis-stating a core feature of Lisp. Am I wrong about this? Does the Tcl world have something significantly different in this regard?
- malkia 16y agoCan you serialize the hash-table?
- derleth 16y agoYes, you can: > (write (make-hash-table :initial-contents '((a . b) (c . d)))) #S(HASH-TABLE :TEST FASTHASH-EQL (C . D) (A . B)) If you wrote the output to a file and used read to input that file, you'd get precisely the same hash table back into your program. (That's Common Lisp. Scheme might be different.)
- pmarin 16y agoDoes hash tables stores only values or they can store other data structures? What happen when they store references to other data structures? In Tcl, list and dict always are values so their string representation is already a serialization.
- pmarin 16y agoTry with a circular list.
- Fixnum 16y ago(setf * print-circle* t)
- pmarin 16y agoIn Tcl lists and dicts always store values.