[racket] Problem writing and reading sets

From: Wayne Iba (iba at westmont.edu)
Date: Sat Jul 6 01:21:27 EDT 2013

Thanks, Carl.  I'd like to avoid the overhead of serialize/deserialize.  I
guess I missed that sets were in a different category than hashes with
respect to this question.  (I was assuming that since I can read in the
write of a hash as a hash, I could do the same with sets.  Is there a
particular reason that's not the case?)


On Fri, Jul 5, 2013 at 1:35 PM, Carl Eastlund <cce at ccs.neu.edu> wrote:

> Wayne,
>
> You cannot read in a set.  If you read in the result of print, you get
> '(set 1 2 3), which is a list beginning with the symbol 'set, not a set.
> Sets are a derived datatype using structs, not a primitive on recognized by
> read and write.  You can use the functions serialize and deserialize to
> store sets, if you need to.
>
> --Carl
>
> On Fri, Jul 5, 2013 at 3:41 PM, Wayne Iba <iba at westmont.edu> wrote:
>
>> If I evaluate (write myset) for myset as (set 1 2 3), the format of the
>> output is "#<set: 1 2 3>", whereas (print myset) produces "(set 1 2 3)".
>> Naturally, I can read in the latter but not the former.  From the docs, I
>> believe the expectation is that we can rely on the output of write for
>> reading, but not necessarily that of print.
>>
>> Am I missing something here or is this a problem with how racket is
>> writing sets?  (I'm using v5.3.5)
>>
>> Thanks,
>> --Wayne
>>
>> ____________________
>>   Racket Users list:
>>   http://lists.racket-lang.org/users
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130705/aace2b9e/attachment.html>

Posted on the users mailing list.