[racket] Transparent Structures in 4.2.1

From: Laurent (laurent.orseau at gmail.com)
Date: Sat Jun 5 08:38:17 EDT 2010

Hi,
you are probably looking for this define-serializable-struct:

http://docs.plt-scheme.org/reference/serialization.html?q=define-serializable-struct#%28form._%28%28lib._scheme/serialize..ss%29._define-serializable-struct%29%29

Transparent structures are not serializable as is (as explained in the
docs).
Prefabs can be though.

HTH,
Laurent

On Sat, Jun 5, 2010 at 13:01, Paulo J. Matos <pocmatos at gmail.com> wrote:

> Hello all,
>
> I am generating code for a unit, which is later then loaded and
> evaluated. My current approach is to convert all structures into a
> 'personally designed' sexpr and then when loaded, the unit converts the
> sexpr back into structures.
>
> I have the feeling that there is currently a better way to do this. I
> want basically to automatically serialise my structures and have the
> unit deserialise them. This would simplify greatly my software by
> removing my hand-coded serialisation implementation.
>
> I thought transparent structures were what I was looking for but after
> trying the following maybe they are not:
> ,----
> | #lang scheme
> |
> | (define-struct xpto
> |   (x y)
> |   #:transparent)
> `----
>
> ,----
> | > (define x (make-xpto 1 2))
> | > x
> | #(struct:xpto 1 2)
> | > (define y #(struct:xpto 1 2))
> | > x
> | #(struct:xpto 1 2)
> | > y
> | #(struct:xpto 1 2)
> | > (xpto-x x)
> | 1
> | > (xpto-x y)
> | . . xpto-x: expects argument of type <struct:xpto>; given #(struct:xpto
> | 1 2)
> `----
>
> So, what's the actual difference here? And how can I obtain the
> automatic serialisation/deserialisation that I need?
>
> Cheers,
>
> --
> PMatos
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users
>
_________________________________________________
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users


Posted on the users mailing list.