Move docs for syntax/transformer from unstable-doc.

This commit is contained in:
Vincent St-Amour 2015-07-31 16:21:22 -05:00
parent 7e93b7d426
commit a1c5285cc2
2 changed files with 40 additions and 0 deletions

View File

@ -10,3 +10,4 @@
@include-section["struct.scrbl"] @include-section["struct.scrbl"]
@include-section["path-spec.scrbl"] @include-section["path-spec.scrbl"]
@include-section["template.scrbl"] @include-section["template.scrbl"]
@include-section["transformer.scrbl"]

View File

@ -0,0 +1,39 @@
#lang scribble/doc
@(require "common.rkt" scribble/eval (for-label syntax/transformer))
@(define the-eval (make-base-eval))
@(the-eval '(require syntax/transformer (for-syntax racket/base syntax/transformer)))
@title[#:tag "syntax/transformer"]{Creating Macro Transformers}
@defmodule[syntax/transformer]
@defproc[(make-variable-like-transformer [reference-stx syntax?]
[setter-stx (or/c syntax? #f) #f])
set!-transformer?]{
Creates a transformer that replaces references to the macro identifier
with @racket[reference-stx]. Uses of the macro in operator position
are interpreted as an application with @racket[reference-stx] as the
function and the arguments as given.
If the macro identifier is used as the target of a @racket[set!] form,
then the @racket[set!] form expands into the application of
@racket[setter-stx] to the @racket[set!] expression's right-hand side,
if @racket[setter-stx] is syntax; otherwise, the identifier is
considered immutable and a syntax error is raised.
@examples[#:eval the-eval
(define the-box (box add1))
(define-syntax op
(make-variable-like-transformer
#'(unbox the-box)
#'(lambda (v) (set-box! the-box v))))
(op 5)
(set! op 0)
op
]
}
@close-eval[the-eval]