document procedure behavior of make-variable-like-transformer

This commit is contained in:
AlexKnauth 2019-03-18 09:56:44 -04:00 committed by Ryan Culpepper
parent 780647f0eb
commit b471b18876

View File

@ -8,20 +8,24 @@
@defmodule[syntax/transformer] @defmodule[syntax/transformer]
@defproc[(make-variable-like-transformer [reference-stx syntax?] @defproc[(make-variable-like-transformer
[setter-stx (or/c syntax? #f) #f]) [reference-stx (or/c syntax? (-> identifier? syntax?))]
set!-transformer?]{ [setter-stx (or/c syntax? (-> syntax? syntax?) #f) #f])
(and/c set!-transformer? (-> syntax? syntax?))]{
Creates a transformer that replaces references to the macro identifier Creates a transformer that replaces references to the macro identifier
with @racket[reference-stx]. Uses of the macro in operator position with @racket[reference-stx]. Uses of the macro in operator position
are interpreted as an application with @racket[reference-stx] as the are interpreted as an application with @racket[reference-stx] as the
function and the arguments as given. function and the arguments as given. If the @racket[reference-stx] is
a procedure, it is applied to the macro identifier.
If the macro identifier is used as the target of a @racket[set!] form, If the macro identifier is used as the target of a @racket[set!] form,
then the @racket[set!] form expands into the application of then the @racket[set!] form expands into the application of
@racket[setter-stx] to the @racket[set!] expression's right-hand side, @racket[setter-stx] to the @racket[set!] expression's right-hand side,
if @racket[setter-stx] is syntax; otherwise, the identifier is if @racket[setter-stx] is syntax; otherwise, the identifier is
considered immutable and a syntax error is raised. considered immutable and a syntax error is raised. If
@racket[setter-stx] is a procedure, it is applied to the entire
@racket[set!] expression.
@examples[#:eval the-eval @examples[#:eval the-eval
(define the-box (box add1)) (define the-box (box add1))