This is because `prop:impersonator-of` only applies to two instances that
inherit the property from the same structure type. (As the docs put it,
"The result value must have the same prop:impersonator-of and
prop:equal+hash property values as the original structure, if any, and the
property values must be inherited from the same structure type (which
ensures some consistency between impersonator-of? and equal?).")

The following works:

#lang racket

(struct our-impersonate-proc (f orig)
  #:property prop:impersonator-of (lambda (x) (displayln 'hi)
(our-impersonate-proc-orig x))
  #:property prop:procedure (struct-field-index f))

(let ([values (our-impersonate-proc values #f)])
  (impersonator-of?
   (our-impersonate-proc add1 values)
   values))

-Philip

On Thu, Jan 25, 2018 at 4:45 PM, Daniel Feltey <
daniel.fel...@eecs.northwestern.edu> wrote:

> I'm trying to understand the use of the prop:impersonator-of struct
> property, but the following program doesn't work the way I would have
> expected:
>
> #lang racket
>
> (struct our-impersonate-proc (f orig)
>  #:property prop:impersonator-of (lambda (x) (displayln 'hi)
> (our-impersonate-proc-orig x))
>  #:property prop:procedure (struct-field-index f))
>
> (impersonator-of?
>   (our-impersonate-proc add1 values)
>   values)
>
> The call to impersonator-of? doesn't seem to go through our
> prop:impersonator-of at all because we don't 'hi displayed when the program
> is run.
>
> Am I misunderstanding the way to use prop:impersonator-of ? I don't fully
> understand the documentation, so it's possible this isn't something that
> prop:impersonator-of is intended for.
>
> Thanks
> Dan
>
>
> --
> 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 racket-users+unsubscr...@googlegroups.com.
> 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 racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to