Clean up the documentation on cross phase persistent modules (#2275)

This commit is contained in:
Leif Andersen 2018-10-08 13:29:53 -04:00 committed by GitHub
parent 1d8806e0bb
commit 04a2c54d56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -749,12 +749,42 @@ syntactic extensions in its presence.
@;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@subsection[#:tag "cross-phase persistent-modules"]{Cross-Phase Persistent Modules}
Module declarations that fit a highly constrained form---including a
@racket[(#%declare #:cross-phase-persistent)] form in the module
body---create @deftech{cross-phase persistent} modules. A
@tech{cross-phase persistent} module's instantiations across all
phases and @tech{module registries} share the variables produced by
the first instantiation of the module.
Module declarations that fit a highly constrained
form---including a
@racket[(#%declare #:cross-phase-persistent)] form in the
module body---create @deftech{cross-phase persistent}
modules. A @tech{cross-phase persistent} module's
instantiations across all phases share the variables
produced by the first instantiation of the module.
Additionally, @tech{cross-phase persistent} module
instantiations persist across @tech{module registries} when
they share a common module declaration.
@examples[
(module cross '#%kernel
(#%declare #:cross-phase-persistent)
(#%provide x)
(define-values (x) (gensym)))
(module noncross '#%kernel
(#%provide x)
(define-values (x) (gensym)))
(define ns (current-namespace))
(define (same-instence? mod)
(namespace-require mod)
(define a
(parameterize ([current-namespace (make-base-namespace)])
(namespace-attach-module-declaration ns mod)
(namespace-require mod)
(namespace-variable-value 'x)))
(define b
(parameterize ([current-namespace (make-base-namespace)])
(namespace-attach-module-declaration ns mod)
(namespace-require mod)
(namespace-variable-value 'x)))
(eq? a b))
(same-instence? ''noncross)
(same-instence? ''cross)
]
The intent of a @tech{cross-phase persistent} module is to support values that are
recognizable after @tech{phase} crossings. For example, when a macro