[gambit-list] READ for things other than lists

Marc Feeley feeley at iro.umontreal.ca
Fri May 22 07:34:38 EDT 2009


On 22-May-09, at 5:29 AM, FFT wrote:

> It appears that while WRITE works for just about anything, READ does
> not work for vectors, structures and probably other things. Is there a
> simple way to convince READ to recognize what WRITE has written?
> (Clojure does it)

Read certainly works for vectors.

For records defined with define-type, you will need to set the port's  
readtable so that it's sharing-allowed? field is 'serialize.  Look at  
the examples for the procedure readtable-sharing-allowed?-set.  For  
serialization/deserialization to work, you will need to specify an id:  
for the record type, for example:

(define-type person
    id: 00FB6830-D7EC-48E4-9332-94FCD006167B
    name
    sex
)

Otherwise, the record when read back will not be a "person" of the  
same type.

Marc




More information about the Gambit-list mailing list