racket/{require,provide}-syntax: add `syntax-local-{require,provide}-introduce'
This commit is contained in:
parent
8db95d007a
commit
0b1c0ba13b
|
@ -1,6 +1,7 @@
|
|||
#lang racket/base
|
||||
|
||||
(provide define-provide-syntax)
|
||||
(provide define-provide-syntax
|
||||
(for-syntax syntax-local-provide-introduce))
|
||||
|
||||
(require (for-syntax racket/base
|
||||
"provide-transform.rkt"))
|
||||
|
@ -8,12 +9,21 @@
|
|||
(define-for-syntax orig-insp (variable-reference->module-declaration-inspector
|
||||
(#%variable-reference)))
|
||||
|
||||
(define-for-syntax current-provide-introducer
|
||||
(make-parameter (lambda (x) (error "not expanding provide form"))))
|
||||
|
||||
(define-for-syntax (syntax-local-provide-introduce x)
|
||||
(unless (syntax? x)
|
||||
(raise-argument-error 'syntax-local-introduce-provide "syntax?" x))
|
||||
((current-provide-introducer) x))
|
||||
|
||||
(define-for-syntax (make-provide-macro proc)
|
||||
(make-provide-transformer
|
||||
(lambda (stx modes)
|
||||
(let* ([i (make-syntax-introducer)]
|
||||
[d-stx (syntax-disarm stx orig-insp)]
|
||||
[new-stx (i (proc (i d-stx)))])
|
||||
[new-stx (parameterize ([current-provide-introducer i])
|
||||
(i (proc (i d-stx))))])
|
||||
(expand-export (syntax-rearm new-stx stx) modes)))))
|
||||
|
||||
(define-syntax (define-provide-syntax stx)
|
||||
|
|
|
@ -1,18 +1,28 @@
|
|||
#lang racket/base
|
||||
|
||||
(provide define-require-syntax)
|
||||
(provide define-require-syntax
|
||||
(for-syntax syntax-local-require-introduce))
|
||||
|
||||
(require (for-syntax racket/base "require-transform.rkt"))
|
||||
|
||||
(define-for-syntax orig-insp (variable-reference->module-declaration-inspector
|
||||
(#%variable-reference)))
|
||||
|
||||
(define-for-syntax current-require-introducer
|
||||
(make-parameter (lambda (x) (error "not expanding require form"))))
|
||||
|
||||
(define-for-syntax (syntax-local-require-introduce x)
|
||||
(unless (syntax? x)
|
||||
(raise-argument-error 'syntax-local-introduce-require "syntax?" x))
|
||||
((current-require-introducer) x))
|
||||
|
||||
(define-for-syntax (make-require-macro proc)
|
||||
(make-require-transformer
|
||||
(lambda (stx)
|
||||
(let* ([i (make-syntax-introducer)]
|
||||
[d-stx (syntax-disarm stx orig-insp)]
|
||||
[new-stx (i (proc (i d-stx)))])
|
||||
[new-stx (parameterize ([current-require-introducer i])
|
||||
(i (proc (i d-stx))))])
|
||||
(expand-import (syntax-rearm new-stx stx))))))
|
||||
|
||||
(define-syntax (define-require-syntax stx)
|
||||
|
|
|
@ -2498,13 +2498,22 @@ procedure that accepts and returns a syntax object representing a
|
|||
@racket[require] sub-form.
|
||||
|
||||
This form expands to @racket[define-syntax] with a use of
|
||||
@racket[make-require-transformer]; see @secref["require-trans"] for
|
||||
more information.
|
||||
@racket[make-require-transformer] (see @secref["require-trans"] for
|
||||
more information), and the @tech{syntax object} passed to and from the
|
||||
macro transformer is marked via @racket[syntax-local-require-introduce].
|
||||
|
||||
The second form is a shorthand the same as for @racket[define-syntax]; it
|
||||
expands to a definition of the first form where the @racket[expr] is a
|
||||
expands to a definition of the first form where the @racket[proc-expr] is a
|
||||
@racket[lambda] form.}
|
||||
|
||||
@defproc[(syntax-local-require-introduce [stx syntax?])
|
||||
syntax?]{
|
||||
|
||||
Provided @racket[for-syntax] for use only during the application of a
|
||||
@racket[require] sub-form macro transformer: like
|
||||
@racket[syntax-local-introduce], but for @racket[require] sub-form
|
||||
expansion.}
|
||||
|
||||
@; ----------------------------------------------------------------------
|
||||
|
||||
@subsection[#:tag "provide-syntax"]{@racket[provide] Macros}
|
||||
|
@ -2520,13 +2529,22 @@ procedure that accepts and returns a syntax object representing a
|
|||
@racket[provide] sub-form.
|
||||
|
||||
This form expands to @racket[define-syntax] with a use of
|
||||
@racket[make-provide-transformer]; see @secref["provide-trans"] for
|
||||
more information.
|
||||
@racket[make-provide-transformer] (see @secref["provide-trans"] for
|
||||
more information), and the @tech{syntax object} passed to and from the
|
||||
macro transformer is marked via @racket[syntax-local-provide-introduce].
|
||||
|
||||
The second form is a shorthand the same as for @racket[define-syntax]; it
|
||||
expands to a definition of the first form where the @racket[expr] is a
|
||||
@racket[lambda] form.}
|
||||
|
||||
@defproc[(syntax-local-provide-introduce [stx syntax?])
|
||||
syntax?]{
|
||||
|
||||
Provided @racket[for-syntax] for use only during the application of a
|
||||
@racket[provide] sub-form macro transformer: like
|
||||
@racket[syntax-local-introduce], but for @racket[provide] sub-form
|
||||
expansion.}
|
||||
|
||||
@;------------------------------------------------------------------------
|
||||
@section[#:tag "begin"]{Sequencing: @racket[begin], @racket[begin0], and @racket[begin-for-syntax]}
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
Version 5.3.4.8
|
||||
Add `configure-runtime' submodule support
|
||||
racket/rerequire: added
|
||||
racket/require-syntax: added syntax-local-require-introduce
|
||||
racket/provide-syntax: added syntax-local-provide-introduce
|
||||
|
||||
Version 5.3.4.7
|
||||
scribble: use `doc' submodule when available
|
||||
|
|
Loading…
Reference in New Issue
Block a user