Mutable values generally cannot be sent as messages on place channels. ("To
a first approximation, place channels support only immutable, transparent
values as messages." http://docs.racket-lang.org/reference/places.html The
documentation for `place-message-allowed?` is also specific that only
"immutable prefab structures containing message-allowed values" are
accepted.)The reason for this restriction becomes clear if we think of places as separate instances of the Racket VM. With Racket threads, mutable values can be shared among all threads running concurrently, so mutation has the expected effect and changes that shared structure. With places, only values explicitly created in the shared memory space (via functions like `shared-bytes`) are shared. An instance of a struct received from a place channel isn't connected to the instance sent from a different place: mutating one wouldn't change the other. With things like vectors and hash tables where Racket has both mutable and immutable variants, place channel operations automatically convert mutable values to immutable ones for convenience, but there is no such substitution for user-defined data types. If you need to send mutable structures across place channels, I would suggest that you first serialize them with racket/serialize, then send the serialized representation across the place channel. -Philip On Tue, Mar 20, 2018 at 5:39 AM, 'Paulo Matos' via Racket Users < [email protected]> wrote: > Hi, > > I was quite surprised by a 'feature' of prefab mutable structures: > #lang racket > > (struct f (a b) > #:prefab > #:mutable) > > (place-message-allowed? (f 1 2)) > (place-message-allowed? #s(f 1 2)) > > I was expecting both to return true but to my amazement it was not the > case. The one created with #s(...) returned true while the other > returned false. This is surprising because I thought I had read > everything about prefabs and never seen this distinction being discussed. > > Any reasons for this to happen? > > -- > Paulo Matos > > -- > You received this message because you are subscribed to the Google Groups > "Racket Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

