Discussion:
[racket] Units and serializable-struct
Justin Zamora
2015-02-04 21:19:23 UTC
Permalink
I am writing a program using units and got this message:
define-signature: unknown signature form in: serializable-struct

Sure enough, the docs show that serializable-struct is not allowed in a
signature. Is this something that can be fixed or do I have to work around
it (maybe by using regular structs and writing my own read-struct and
write-struct routines)? What is the best course of action?

Justin
Matthew Flatt
2015-02-05 07:35:18 UTC
Permalink
The `struct` form in a signature describes a structure type that will
be implemented by some unit. It can't work to have a similar
`serializable-struct` form in a signature, because different units can
implement a signature with different structure types, and a
deserializer can't know which one to create.

Using `define-serializable-struct` in a `unit` form won't work, either.
That's because each instantiation of the unit create a different
structure type (assuming that the structure type is not prefab), which
leads to the same problem for the deserializer.

So, `define-serializable-struct` needs to be used outside of a
signature and outside of any unit. It could be in its own module, for
example.
Post by Justin Zamora
define-signature: unknown signature form in: serializable-struct
Sure enough, the docs show that serializable-struct is not allowed in a
signature. Is this something that can be fixed or do I have to work around
it (maybe by using regular structs and writing my own read-struct and
write-struct routines)? What is the best course of action?
Justin
____________________
http://lists.racket-lang.org/users
____________________
Racket Users list:
http://lists.racket-lang.org/users
Justin Zamora
2015-02-05 11:53:39 UTC
Permalink
That makes sense. Thanks.

Justin
Post by Matthew Flatt
The `struct` form in a signature describes a structure type that will
be implemented by some unit. It can't work to have a similar
`serializable-struct` form in a signature, because different units can
implement a signature with different structure types, and a
deserializer can't know which one to create.
Using `define-serializable-struct` in a `unit` form won't work, either.
That's because each instantiation of the unit create a different
structure type (assuming that the structure type is not prefab), which
leads to the same problem for the deserializer.
So, `define-serializable-struct` needs to be used outside of a
signature and outside of any unit. It could be in its own module, for
example.
Post by Justin Zamora
define-signature: unknown signature form in: serializable-struct
Sure enough, the docs show that serializable-struct is not allowed in a
signature. Is this something that can be fixed or do I have to work
around
Post by Justin Zamora
it (maybe by using regular structs and writing my own read-struct and
write-struct routines)? What is the best course of action?
Justin
____________________
http://lists.racket-lang.org/users
Loading...