From e3e141d1fd96c7fb854d4942d18527de9029ed9e Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Fri, 17 May 2019 22:40:39 -0400 Subject: [PATCH] adjust spec of `impersonator?` w.r.t. `prop:impersonator-of` As implemented, `impersonator?` does not recognize values that impersponate others via `prop:impersonator-of`. Meanwhile, the use of `impersonator?` in the (unenforced) contract of `unsafe-struct*-ref` makes sense with that implementation, as does the offered rationale for sometimes using `impersonator?`. So, adjust the specification in the documentations, instead of adjusting the implementation. --- .../scribblings/reference/chaperones.scrbl | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pkgs/racket-doc/scribblings/reference/chaperones.scrbl b/pkgs/racket-doc/scribblings/reference/chaperones.scrbl index 4980bfebea..28fa039499 100644 --- a/pkgs/racket-doc/scribblings/reference/chaperones.scrbl +++ b/pkgs/racket-doc/scribblings/reference/chaperones.scrbl @@ -65,12 +65,20 @@ types and their instances. @defproc[(impersonator? [v any/c]) boolean?]{ -Returns @racket[#t] if @racket[v] is an @tech{impersonator}, @racket[#f] otherwise. +Returns @racket[#t] if @racket[v] is an @tech{impersonator} created by +procedures like @racket[impersonate-procedure] or +@racket[impersonate-struct], @racket[#f] otherwise. Programs and libraries generally should avoid @racket[impersonator?] and treat impersonators the same as non-impersonator values. In rare cases, @racket[impersonator?] may be needed to guard against redirection by an -impersonator of an operation to an arbitrary procedure.} +impersonator of an operation to an arbitrary procedure. + +A limitation of @racket[impersonator?] is that it does @emph{not} +recognize an @tech{impersonator} that is created by instantiating a +structure type with the @racket[prop:impersonator-of] property. The +limitation reflects how those impersonators cannot redirect structure +access and mutation operations to arbitrary procedures.} @defproc[(chaperone? [v any/c]) boolean?]{ @@ -78,7 +86,9 @@ impersonator of an operation to an arbitrary procedure.} Returns @racket[#t] if @racket[v] is a @tech{chaperone}, @racket[#f] otherwise. Programs and libraries generally should avoid @racket[chaperone?] for -the same reason that they should avoid @racket[impersonator?].} +the same reason that they should avoid @racket[impersonator?]. A true +value for @racket[chaperone?] implies a true value of +@racket[impersonator?].} @defproc[(impersonator-of? [v1 any/c] [v2 any/c]) boolean?]{