Make syntax-local-introduce work in require/provide syntax
This commit is contained in:
parent
2bccbf76ad
commit
33546008b3
|
@ -2583,20 +2583,17 @@ procedure that accepts and returns a syntax object representing a
|
||||||
|
|
||||||
This form expands to @racket[define-syntax] with a use of
|
This form expands to @racket[define-syntax] with a use of
|
||||||
@racket[make-require-transformer] (see @secref["require-trans"] for
|
@racket[make-require-transformer] (see @secref["require-trans"] for
|
||||||
more information), and the @tech{syntax object} passed to and from the
|
more information).
|
||||||
macro transformer is adjusted via @racket[syntax-local-require-introduce].
|
|
||||||
|
|
||||||
The second form is a shorthand the same as for @racket[define-syntax]; it
|
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[proc-expr] is a
|
expands to a definition of the first form where the @racket[proc-expr] is a
|
||||||
@racket[lambda] form.}
|
@racket[lambda] form.}
|
||||||
|
|
||||||
@defproc[(syntax-local-require-introduce [stx syntax?])
|
@defproc[(syntax-local-require-introduce [stx syntax?]) syntax?]{
|
||||||
syntax?]{
|
|
||||||
|
|
||||||
Provided @racket[for-syntax] for use only during the application of a
|
For backward compatibility only; equivalent to @racket[syntax-local-introduce].
|
||||||
@racket[require] sub-form macro transformer: like
|
|
||||||
@racket[syntax-local-introduce], but for @racket[require] sub-form
|
@history[#:changed "6.90.0.29" @elem{Made equivalent to @racket[syntax-local-introduce].}]}
|
||||||
expansion.}
|
|
||||||
|
|
||||||
@; ----------------------------------------------------------------------
|
@; ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -2614,20 +2611,17 @@ procedure that accepts and returns a syntax object representing a
|
||||||
|
|
||||||
This form expands to @racket[define-syntax] with a use of
|
This form expands to @racket[define-syntax] with a use of
|
||||||
@racket[make-provide-transformer] (see @secref["provide-trans"] for
|
@racket[make-provide-transformer] (see @secref["provide-trans"] for
|
||||||
more information), and the @tech{syntax object} passed to and from the
|
more information).
|
||||||
macro transformer is adjusted via @racket[syntax-local-provide-introduce].
|
|
||||||
|
|
||||||
The second form is a shorthand the same as for @racket[define-syntax]; it
|
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[expr] is a
|
||||||
@racket[lambda] form.}
|
@racket[lambda] form.}
|
||||||
|
|
||||||
@defproc[(syntax-local-provide-introduce [stx syntax?])
|
@defproc[(syntax-local-provide-introduce [stx syntax?]) syntax?]{
|
||||||
syntax?]{
|
|
||||||
|
|
||||||
Provided @racket[for-syntax] for use only during the application of a
|
For backward compatibility only; equivalent to @racket[syntax-local-introduce].
|
||||||
@racket[provide] sub-form macro transformer: like
|
|
||||||
@racket[syntax-local-introduce], but for @racket[provide] sub-form
|
@history[#:changed "6.90.0.29" @elem{Made equivalent to @racket[syntax-local-introduce].}]}
|
||||||
expansion.}
|
|
||||||
|
|
||||||
@;------------------------------------------------------------------------
|
@;------------------------------------------------------------------------
|
||||||
@section[#:tag "begin"]{Sequencing: @racket[begin], @racket[begin0], and @racket[begin-for-syntax]}
|
@section[#:tag "begin"]{Sequencing: @racket[begin], @racket[begin0], and @racket[begin-for-syntax]}
|
||||||
|
|
|
@ -4,27 +4,18 @@
|
||||||
(for-syntax syntax-local-provide-introduce))
|
(for-syntax syntax-local-provide-introduce))
|
||||||
|
|
||||||
(require (for-syntax racket/base
|
(require (for-syntax racket/base
|
||||||
|
syntax/apply-transformer
|
||||||
"provide-transform.rkt"))
|
"provide-transform.rkt"))
|
||||||
|
|
||||||
(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)
|
(define-for-syntax (syntax-local-provide-introduce x)
|
||||||
(unless (syntax? x)
|
(unless (syntax? x)
|
||||||
(raise-argument-error 'syntax-local-introduce-provide "syntax?" x))
|
(raise-argument-error 'syntax-local-introduce-provide "syntax?" x))
|
||||||
((current-provide-introducer) x))
|
(syntax-local-introduce x))
|
||||||
|
|
||||||
(define-for-syntax (make-provide-macro proc)
|
(define-for-syntax (make-provide-macro proc)
|
||||||
(make-provide-transformer
|
(make-provide-transformer
|
||||||
(lambda (stx modes)
|
(lambda (stx modes)
|
||||||
(let* ([i (make-syntax-introducer)]
|
(expand-export (local-apply-transformer proc stx 'expression) modes))))
|
||||||
[d-stx (syntax-disarm stx orig-insp)]
|
|
||||||
[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)
|
(define-syntax (define-provide-syntax stx)
|
||||||
(syntax-case stx ()
|
(syntax-case stx ()
|
||||||
|
|
|
@ -3,27 +3,19 @@
|
||||||
(provide define-require-syntax
|
(provide define-require-syntax
|
||||||
(for-syntax syntax-local-require-introduce))
|
(for-syntax syntax-local-require-introduce))
|
||||||
|
|
||||||
(require (for-syntax racket/base "require-transform.rkt"))
|
(require (for-syntax racket/base
|
||||||
|
syntax/apply-transformer
|
||||||
(define-for-syntax orig-insp (variable-reference->module-declaration-inspector
|
"require-transform.rkt"))
|
||||||
(#%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)
|
(define-for-syntax (syntax-local-require-introduce x)
|
||||||
(unless (syntax? x)
|
(unless (syntax? x)
|
||||||
(raise-argument-error 'syntax-local-introduce-require "syntax?" x))
|
(raise-argument-error 'syntax-local-introduce-require "syntax?" x))
|
||||||
((current-require-introducer) x))
|
(syntax-local-introduce x))
|
||||||
|
|
||||||
(define-for-syntax (make-require-macro proc)
|
(define-for-syntax (make-require-macro proc)
|
||||||
(make-require-transformer
|
(make-require-transformer
|
||||||
(lambda (stx)
|
(lambda (stx)
|
||||||
(let* ([i (make-syntax-introducer)]
|
(expand-import (local-apply-transformer proc stx 'expression)))))
|
||||||
[d-stx (syntax-disarm stx orig-insp)]
|
|
||||||
[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)
|
(define-syntax (define-require-syntax stx)
|
||||||
(syntax-case stx ()
|
(syntax-case stx ()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user