moved phase-of-enclosing-module to unstable/syntax
closes PR 11970
This commit is contained in:
parent
c8a691490a
commit
5bf4b1c930
|
@ -7,7 +7,8 @@
|
||||||
"rep-data.rkt"
|
"rep-data.rkt"
|
||||||
"rep.rkt"
|
"rep.rkt"
|
||||||
"kws.rkt")
|
"kws.rkt")
|
||||||
"runtime.rkt")
|
"runtime.rkt"
|
||||||
|
(only-in unstable/syntax phase-of-enclosing-module))
|
||||||
(provide define-conventions
|
(provide define-conventions
|
||||||
define-literal-set
|
define-literal-set
|
||||||
literal-set->predicate
|
literal-set->predicate
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
(require (for-template racket/base
|
(require (for-template racket/base
|
||||||
racket/stxparam
|
racket/stxparam
|
||||||
"keywords.rkt"
|
"keywords.rkt"
|
||||||
"runtime.rkt")
|
"runtime.rkt"
|
||||||
|
(only-in unstable/syntax phase-of-enclosing-module))
|
||||||
racket/contract/base
|
racket/contract/base
|
||||||
"minimatch.rkt"
|
"minimatch.rkt"
|
||||||
syntax/id-table
|
syntax/id-table
|
||||||
|
|
|
@ -369,16 +369,3 @@
|
||||||
;; For now, let #%app handle it.
|
;; For now, let #%app handle it.
|
||||||
(with-syntax ([((kw-part ...) ...) #'((kw kwarg) ...)])
|
(with-syntax ([((kw-part ...) ...) #'((kw kwarg) ...)])
|
||||||
#'(proc kw-part ... ... extra-parg ... parg ...))]))
|
#'(proc kw-part ... ... extra-parg ... parg ...))]))
|
||||||
|
|
||||||
;; ----
|
|
||||||
|
|
||||||
(provide phase-of-enclosing-module)
|
|
||||||
|
|
||||||
(define-syntax (phase-of-enclosing-module stx)
|
|
||||||
(syntax-case stx ()
|
|
||||||
[(poem)
|
|
||||||
(let ([phase-within-module (syntax-local-phase-level)])
|
|
||||||
#`(let ([phase-of-this-expression
|
|
||||||
(variable-reference->phase (#%variable-reference))])
|
|
||||||
(- phase-of-this-expression
|
|
||||||
#,(if (zero? phase-within-module) 0 1))))]))
|
|
||||||
|
|
|
@ -26,6 +26,25 @@ resolved module path or @racket[#f] for the ``self'' module.
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@defform[(phase-of-enclosing-module)]{
|
||||||
|
|
||||||
|
Returns the phase level of the module in which the form occurs (and
|
||||||
|
for the instantiation of the module in which the form is
|
||||||
|
executed). For example, if a module is required directly by the
|
||||||
|
``main'' module (or the top level), its phase level is 0. If a module
|
||||||
|
is required for-syntax by the ``main'' module (or the top level), its
|
||||||
|
phase level is 1.
|
||||||
|
|
||||||
|
@examples[#:eval the-eval
|
||||||
|
(module helper racket
|
||||||
|
(require unstable/syntax)
|
||||||
|
(displayln (phase-of-enclosing-module)))
|
||||||
|
(require 'helper)
|
||||||
|
(require (for-meta 1 'helper))
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@;{----}
|
@;{----}
|
||||||
|
|
||||||
@addition{@author+email["Vincent St-Amour" "stamourv@racket-lang.org"]}
|
@addition{@author+email["Vincent St-Amour" "stamourv@racket-lang.org"]}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
#lang racket/base
|
#lang racket/base
|
||||||
;; owner: ryanc (and cce and stamourv, where noted)
|
;; owner: ryanc (and cce and stamourv, where noted)
|
||||||
(require racket/syntax
|
(require racket/syntax
|
||||||
syntax/stx)
|
syntax/stx
|
||||||
|
(for-syntax racket/base))
|
||||||
|
|
||||||
(provide (rename-out [stx-map syntax-map])
|
(provide (rename-out [stx-map syntax-map])
|
||||||
syntax-list
|
syntax-list
|
||||||
|
@ -15,7 +16,8 @@
|
||||||
syntax-within?
|
syntax-within?
|
||||||
|
|
||||||
;; by ryanc
|
;; by ryanc
|
||||||
explode-module-path-index)
|
explode-module-path-index
|
||||||
|
phase-of-enclosing-module)
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;;
|
;;
|
||||||
|
@ -82,3 +84,12 @@
|
||||||
(if (module-path-index? y)
|
(if (module-path-index? y)
|
||||||
(explode-module-path-index y)
|
(explode-module-path-index y)
|
||||||
(list y)))))
|
(list y)))))
|
||||||
|
|
||||||
|
(define-syntax (phase-of-enclosing-module stx)
|
||||||
|
(syntax-case stx ()
|
||||||
|
[(poem)
|
||||||
|
(let ([phase-within-module (syntax-local-phase-level)])
|
||||||
|
#`(let ([phase-of-this-expression
|
||||||
|
(variable-reference->phase (#%variable-reference))])
|
||||||
|
(- phase-of-this-expression
|
||||||
|
#,(if (zero? phase-within-module) 0 1))))]))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user