Expand (require A ...) into (begin (require A) ...)
- docs (including discussion of require scoping) - tests svn: r14232
This commit is contained in:
parent
1c9f11717c
commit
40b4731106
|
@ -317,12 +317,12 @@
|
|||
(syntax->list #'(elem ...))))]
|
||||
[_ (transform-simple in 0 #| run phase |#)]))])
|
||||
(syntax-case stx ()
|
||||
[(_ in ...)
|
||||
(with-syntax ([(new-in ...)
|
||||
(apply append
|
||||
(map transform-one (syntax->list #'(in ...))))])
|
||||
[(_ in)
|
||||
(with-syntax ([(new-in ...) (transform-one #'in)])
|
||||
(syntax/loc stx
|
||||
(#%require new-in ...)))])))
|
||||
(#%require new-in ...)))]
|
||||
[(_ in ...)
|
||||
(syntax/loc stx (begin (require in) ...))])))
|
||||
|
||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; require transformers
|
||||
|
|
|
@ -272,7 +272,8 @@ In a @tech{top-level context}, @scheme[require] instantiates modules
|
|||
(see @secref["module-eval-model"]). In a @tech{module context},
|
||||
@scheme[require] @tech{visits} modules (see @secref["mod-parse"]). In
|
||||
both contexts, @scheme[require] introduces bindings into a
|
||||
@tech{namespace} or a module (see @secref["intro-binding"]). A
|
||||
@tech{namespace} or a module (see @secref["intro-binding"]).
|
||||
A
|
||||
@scheme[require] form in a @tech{expression context} or
|
||||
@tech{internal-definition context} is a syntax error.
|
||||
|
||||
|
@ -283,6 +284,12 @@ be different from the symbolic name of the originally exported
|
|||
identifier. Each identifier also binds at a particular @tech{phase
|
||||
level}.
|
||||
|
||||
A @scheme[require] scopes over all subsequent forms in @tech{top-level
|
||||
contexts}, and all subsequent module top-level forms in a @tech{module
|
||||
context} as well as all expression forms in a module. In both cases,
|
||||
each @scheme[require-spec] scopes over all subsequent
|
||||
@scheme[require-spec]s in them same @scheme[require] form.
|
||||
|
||||
The syntax of @scheme[require-spec] can be extended via
|
||||
@scheme[define-require-syntax], but the
|
||||
pre-defined forms are as follows.
|
||||
|
|
|
@ -236,6 +236,23 @@
|
|||
(require 'p3_cr)
|
||||
(test 18 values w_cr)
|
||||
|
||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Test `require' scoping
|
||||
|
||||
|
||||
(module fake-prefix-in scheme
|
||||
(require scheme/require-syntax)
|
||||
(define-require-syntax (pseudo-+ stx)
|
||||
(syntax-case stx ()
|
||||
[(_ id)
|
||||
#'(only-in scheme [+ id])]))
|
||||
(provide pseudo-+))
|
||||
|
||||
(require 'fake-prefix-in
|
||||
(pseudo-+ ++))
|
||||
(test 12 values (++ 7 5))
|
||||
|
||||
|
||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Test proper bindings for `#%module-begin'
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user