[racket-dev] impersonate-struct with only impersonator properties
At Tue, 19 Jun 2012 23:25:47 -0700, Eric Dobson wrote:
> The documentation for impersonate-struct and chaperone-struct differ
> in the fact that chaperone-struct explicitly says that only
> impersonator properties are not allowed. But the implementation
> doesn't allow it for either of them. Either the documentation or the
> implementation is wrong.
The docs are wrong. I'll fix that...
> What is the reasoning behind the implementation?
At some level, all Racket values are implemented as structs, but the
implementation of impersonator properties relies on a particular
representation of structs.
By supplying some operation to replace other than an
impersonator-property accessor, you provide a witness that the value is
represented in a way that `impersonate-struct' can handle (without
requiring that, say, `struct?' exposes the representation to everyone).