moved phase-of-enclosing-module to unstable/syntax

closes PR 11970
This commit is contained in:
Ryan Culpepper 2011-06-10 01:58:42 -06:00
parent c8a691490a
commit 5bf4b1c930
5 changed files with 36 additions and 17 deletions

View File

@ -7,7 +7,8 @@
"rep-data.rkt"
"rep.rkt"
"kws.rkt")
"runtime.rkt")
"runtime.rkt"
(only-in unstable/syntax phase-of-enclosing-module))
(provide define-conventions
define-literal-set
literal-set->predicate

View File

@ -2,7 +2,8 @@
(require (for-template racket/base
racket/stxparam
"keywords.rkt"
"runtime.rkt")
"runtime.rkt"
(only-in unstable/syntax phase-of-enclosing-module))
racket/contract/base
"minimatch.rkt"
syntax/id-table

View File

@ -369,16 +369,3 @@
;; For now, let #%app handle it.
(with-syntax ([((kw-part ...) ...) #'((kw kwarg) ...)])
#'(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))))]))

View File

@ -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"]}

View File

@ -1,7 +1,8 @@
#lang racket/base
;; owner: ryanc (and cce and stamourv, where noted)
(require racket/syntax
syntax/stx)
syntax/stx
(for-syntax racket/base))
(provide (rename-out [stx-map syntax-map])
syntax-list
@ -15,7 +16,8 @@
syntax-within?
;; by ryanc
explode-module-path-index)
explode-module-path-index
phase-of-enclosing-module)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
@ -82,3 +84,12 @@
(if (module-path-index? y)
(explode-module-path-index 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))))]))