# 13.11 Cryptographic Hashing
(parameter)	→
(-> or/c symbol?
    (and/c path? complete-path?)
    (cons/c (or/c symbol?
    (and/c path? complete-path?))
    (non-empty-listof symbol?)))```
Returns the path or symbol encapsulated by a [resolved module path](#%28tech._resolved._module._path%29). A list result corresponds to a [submodule](eval-model.html#%28tech._submodule%29) path.
> ```
(module-path? v)  →  boolean?
  v : any/c
```
(current-module-name-resolver)	→
(-> case →
    (resolved-module-path? (or/c #f namespace?) . → . any)
    (module-path?
    (or/c #f resolved-module-path?)
    (or/c #f syntax?)
    boolean?
    . → .
    resolved-module-path?))
(current-module-name-resolver proc) → void?
    proc	:
(-> case →
    (resolved-module-path? (or/c #f namespace?) . → . any)
    (module-path?
    (or/c #f resolved-module-path?)
    (or/c #f syntax?)
    boolean?
    . → .
    resolved-module-path?))```

A [parameter](eval-model.html#%28tech._parameter%29) that determines the current module name resolver, which manages the conversion from other kinds of module references to a [resolved module path](#%28tech._resolved._module._path%29). For example, when the expander encounters ([require](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) module-path) where module-path is not an identifier, then the expander passes 'module-path to the module name resolver to obtain a symbol or resolved module path. When such a [require](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) appears within a module, the module path resolver is also given the name of the enclosing module, so that a relative reference can be converted to an absolute symbol or [resolved module path](#%28tech._resolved._module._path%29).

The default [module name resolver](#%28tech._module._name._resolver%29) uses [collection-file-path](collects.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._collection-file-path%29%29) to convert [lib](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._lib%29%29) and symbolic-shorthand module paths to filesystem paths. The [collection-file-path](collects.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._collection-file-path%29%29) function, in turn, uses the [current-library-collection-links](collects.html#%28def._%28%28quote._~23~25kernel%29._current-library-collection-links%29%29) and [current-library-collection-paths](collects.html#%28def._%28%28quote._~23~25kernel%29._current-library-collection-paths%29%29) parameters.

A [module name resolver](#%28tech._module._name._resolver%29) takes two and four arguments:

-   When given two arguments, the first is a name for a module that is now declared in the current namespace, and the second is optionally a namespace from which the declaration was copied. The module name resolver’s result in this case is ignored.

    The current module name resolver is called with two arguments by [namespace-attach-module](Namespaces.html#%28def._%28%28quote._~23~25kernel%29._namespace-attach-module%29%29) or [namespace-attach-module-declaration](Namespaces.html#%28def._%28%28quote._~23~25kernel%29._namespace-attach-module-declaration%29%29) to notify the resolver that a module declaration was attached to the current namespace (and should not be loaded in the future for the namespace’s [module registry](syntax-model.html#%28tech._module._registry%29)). Evaluation of a module declaration also calls the current module name resolver with two arguments, where the first is the declared module and the second is #f. No other Racket operation invokes the module name resolver with two arguments, but other tools (such as DrRacket) might call this resolver in this mode to avoid redundant module loads.

-   When given four arguments, the first is a module path, equivalent to a quoted module-path for [require](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29). The second is name for the source module, if any, to which the path is relative; if the second argument is #f, the module path is relative to ([or](if.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._or%29%29) ([current-load-relative-directory](eval.html#%28def._%28%28quote._~23~25kernel%29._current-load-relative-directory%29%29)) ([current-directory](Filesystem.html#%28def._%28%28quote._~23~25kernel%29._current-directory%29%29))). The third argument is a [syntax object](syntax-model.html#%28tech._syntax._object%29) that can be used for error reporting, if it is not #f. If the last argument is #t, then the module declaration should be loaded (if it is not already), otherwise the module path should be simply resolved to a name. The result is the resolved name.

For the second case, the standard module name resolver keeps a table per [module registry](syntax-model.html#%28tech._module._registry%29) containing loaded module name. If a resolved module path is not in the table, and #f is not provided as the fourth argument to the [module name resolver](#%28tech._module._name._resolver%29), then the name is put into the table and the corresponding file is loaded with a variant of [load/use-compiled](eval.html#%28def._%28%28quote._~23~25kernel%29._load%2Fuse-compiled%29%29) that passes the expected module name to the [compiled-load handler](eval.html#%28tech._compiled._load._handler%29).

While loading a file, the default [module name resolver](#%28tech._module._name._resolver%29) sets the [current-module-declare-name](#%28def._%28%28quote._~23~25kernel%29._current-module-declare-name%29%29) parameter to the resolved module name (while the [compiled-load handler](eval.html#%28tech._compiled._load._handler%29) sets [current-module-declare-source](#%28def._%28%28quote._~23~25kernel%29._current-module-declare-source%29%29)). Also, the default [module name resolver](#%28tech._module._name._resolver%29) records in a private [continuation mark](eval-model.html#%28tech._continuation._mark%29) the module being loaded, and it checks whether such a mark already exists; if such a continuation mark does exist in the current continuation, then the [exn:fail](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail%29%29) exception is raised with a message about a dependency cycle.

The default module name resolver cooperates with the default [compiled-load handler](eval.html#%28tech._compiled._load._handler%29): on a module-attach notification, bytecode-file information recorded by the [compiled-load handler](eval.html#%28tech._compiled._load._handler%29) for the source namespace’s [module registry](syntax-model.html#%28tech._module._registry%29) is transferred to the target namespace’s [module registry](syntax-model.html#%28tech._module._registry%29).

The default module name resolver also maintains a small, [module registry](syntax-model.html#%28tech._module._registry%29)-specific cache that maps [lib](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._lib%29%29) and symbolic module paths to their resolutions. This cache is consulted before checking parameters such as [current-library-collection-links](collects.html#%28def._%28%28quote._~23~25kernel%29._current-library-collection-links%29%29) and [current-library-collection-paths](collects.html#%28def._%28%28quote._~23~25kernel%29._current-library-collection-paths%29%29), so results may “stick” even if those parameter values change. An entry is added to the cache only when the fourth argument to the module name resolver is true (indicating that a module should be loaded) and only when loading succeeds.

Finally, the default module name resolver potentially treats a [submod](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._submod%29%29) path specially. If the module path as the first element of the [submod](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._submod%29%29) form refers to non-existent collection, then instead of raising an exception, the default module name resolver synthesizes an uninterned symbol module name for the resulting [resolved module path](#%28tech._resolved._module._path%29). This special treatment of submodule paths is consistent with the special treatment of nonexistent submodules by the [compiled-load handler](eval.html#%28tech._compiled._load._handler%29), so that [module-declared?](#%28def._%28%28quote._~23~25kernel%29._module-declared~3f%29%29) can be used more readily to check for the existence of a submodule.

Module loading is suppressed (i.e., #f is supplied as a fourth argument to the module name resolver) when resolving module paths in [syntax objects](syntax-model.html#%28tech._syntax._object%29) (see [Syntax Objects](syntax-model.html#%28part._stxobj-model%29)). When a [syntax object](syntax-model.html#%28tech._syntax._object%29) is manipulated, the current namespace might not match the original namespace for the syntax object, and the module should not necessarily be loaded in the current namespace.

For historical reasons, the default module name resolver currently accepts three arguments, in addition to two and four. Three arguments are treated the same as four arguments with the fourth argument as #t, except that an error is also logged. Support for three arguments will be removed in a future version.

The [current-module-name-resolver](#%28def._%28%28quote._~23~25kernel%29._current-module-name-resolver%29%29) binding is provided as [protected](modprotect.html#%28tech._protected%29) in the sense of [protect-out](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._protect-out%29%29).

Changed in version 6.0.1.12 of package base: Added error logging to the default module name resolver when called with three arguments.
Changed in version 7.0.0.17: Added special treatment of [submod](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._submod%29%29) forms with a nonexistent collection by the default module name resolver.
Changed in version 8.2.0.4: Changed binding to [protected](modprotect.html#%28tech._protected%29).

> ```
(current-module-declare-name)	→
(-> or/c resolved-module-path? #f)
(current-module-declare-name name) → void?
    name	:
(-> or/c resolved-module-path? #f)
```


# 13.11 Cryptographic Hashing
(current-module-declare-source)	→
(-> or/c symbol? (and/c path? complete-path?) #f)
(current-module-declare-source src) → void?
    src	:
(-> or/c symbol? (and/c path? complete-path?) #f)```
A [parameter](eval-model.html#%28tech._parameter%29) that determines source information to be associated with a module when evaluating a [module](module.html#%28form._%28%28quote._~23~25kernel%29._module%29%29) declaration. Source information is used in error messages and reflected by [variable-reference->module-source](Namespaces.html#%28def._%28%28quote._~23~25kernel%29._variable-reference-~3emodule-source%29%29). When the parameter value is #f, the module’s name (as determined by [current-module-declare-name](#%28def._%28%28quote._~23~25kernel%29._current-module-declare-name%29%29)) is used as the source name instead of the parameter value.
> ```
(current-module-path-for-load)	→
(-> or/c #f module-path?
    (and/c syntax?
    (lambda (stx)
    (module-path? (syntax → datum s)))))
(current-module-path-for-load path) → void?
    path	:
(-> or/c #f module-path?
    (and/c syntax?
    (lambda (stx)
    (module-path? (syntax → datum s)))))
```
(parameter)	→```

Returns #t if v is a [module path index](#%28tech._module._path._index%29), #f otherwise.

> ```
(module-path-index-resolve mpi
   [ load?
    src-stx)    →    resolved-module-path?

  mpi : module-path-index?
  load? : any/c = #f
  src-stx : (or/c syntax? #f) = #f
```
(parameter)	→
(-> or/c module-path? #f)```


# 13.11 Cryptographic Hashing
Returns two values: a module path, and a base path—either a [module path index](#%28tech._module._path._index%29), [resolved module path](#%28tech._resolved._module._path%29), or #f—to which the first path is relative.
A #f second result means that the path is relative to an unspecified directory (i.e., its resolution depends on the value of [current-load-relative-directory](eval.html#%28def._%28%28quote._~23~25kernel%29._current-load-relative-directory%29%29) and/or [current-directory](Filesystem.html#%28def._%28%28quote._~23~25kernel%29._current-directory%29%29)).
A #f for the first result implies a #f for the second result, and means that mpi represents “self” (see above). Such a [module path index](#%28tech._module._path._index%29) may have a non-#f submodule path as reported by [module-path-index-submodule](#%28def._%28%28quote._~23~25kernel%29._module-path-index-submodule%29%29).
> ```
(parameter)	→
(-> or/c #f (non-empty-listof symbol?))
```
(parameter)	→
(-> or/c module-path? #f)```

Combines path, base, and submod to create a new [module path index](#%28tech._module._path._index%29). The path argument can be #f only if base is also #f. The submod argument can be a list only when path and base are both #f.

> ```
(compiled-module-expression? v)  →  boolean?
  v : any/c
```
(parameter)	→
(-> or/c symbol? (cons/c symbol? (non-empty-listof symbol?)))```
Takes a module declaration in compiled form and either gets the module’s declared name (when name is not provided) or returns a revised module declaration with the given name.


# 13.11 Cryptographic Hashing
The name is a symbol for a top-level module, or a symbol paired with a list of symbols where the list reflects the [submodule](eval-model.html#%28tech._submodule%29) path to the module starting with the top-level module’s declared name.
> ```
(module-compiled-submodules   compiled-module-code
    non-star?)
  →  (listof compiled-module-expression?)
  compiled-module-code : compiled-module-expression?
  non-star? : any/c
(module-compiled-submodules   compiled-module-code
    non-star?
    submodules)
  →  compiled-module-expression?
  compiled-module-code : compiled-module-expression?
  non-star? : any/c
  submodules : (listof compiled-module-expression?)


# 13.11 Cryptographic Hashing
```
Takes a module declaration in compiled form and either gets the module’s submodules (when submodules is not provided) or returns a revised module declaration with the given submodules. The non-star? argument determines whether the result or new submodule list corresponds to module declarations (when non-star? is true) or module* declarations (when non-star? is #f).

> ```
(module-compiled-imports compiled-module-code)
   →    ( listof ( cons/c ( or/c exact-integer? #f )
> ( listof module-path-index? ) ) )

  compiled-module-code : compiled-module-expression?```

Takes a module declaration in compiled form and returns an association list mapping [phase level](syntax-model.html#%28tech._phase._level%29) shifts (where #f corresponds to a shift into the [label phase level](syntax-model.html#%28tech._label._phase._level%29)) to module references for the module’s explicit imports.

> ```
(module-compiled-exports compiled-module-code
   [ verbosity)

   →    (listof (cons/c phase+space? list?))
(listof (cons/c phase+space? list?))

  compiled-module-code : compiled-module-expression?
  verbosity : (or/c #f 'defined-names) = #f
```
(possibly)	→
(-> listof (cons/c exact-integer? (listof symbol?)))```
Returns an association list mapping [phase level](syntax-model.html#%28tech._phase._level%29) values to symbols that represent variables within the module. These definitions are not directly accessible from source, but they are accessible from bytecode, and the order of the symbols in each list corresponds to an order for bytecode access.


# 13.11 Cryptographic Hashing
Added in version 6.5.0.5 of package base.
> ```
(parameter)	→
(-> or/c #f (vector/c module-path? symbol? any/c))
```
> > > <img src="finger.png" width="24" height="24" alt="+" />See also Module-Handling Configuration in The Racket Guide.

Returns information intended to reflect the “language” of the module’s implementation as originally attached to the syntax of the module’s declaration though the 'module-language syntax property. See also module.

If no information is available for the module, the result is #f. Otherwise, the result is (vector mp name val) such that ((dynamic-require mp name) val) should return function that takes two arguments. The function’s arguments are a key for reflected information and a default value. Acceptable keys and the interpretation of results is up to external tools, such as DrRacket. If no information is available for a given key, the result should be the given default value.

See also module  →  language-info and racket/language-info.

> ```
(module-compiled-cross-phase-persistent? compiled-module-code)
   →   boolean?
  compiled-module-code : compiled-module-expression?```

Returns #t if compiled-module-code represents a [cross-phase persistent](eval-model.html#%28tech._cross._phase._persistent%29) module, #f otherwise.

> ```
(parameter)	→
```
(parameter)	→
(-> or/c void? any/c)```


# 13.11 Cryptographic Hashing
> > > Because [dynamic-require](#%28def._%28%28quote._~23~25kernel%29._dynamic-require%29%29) is a procedure, giving a plain S-expression for mod the same way as you would for a [require](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) expression likely won’t give you expected results. What you need instead is something that evaluates to an S-expression; using [quote](quote.html#%28form._%28%28quote._~23~25kernel%29._quote%29%29) is one way to do it.
Dynamically [instantiates](eval-model.html#%28tech._instantiate%29) the module specified by mod in the current namespace’s registry at the namespace’s [base phase](syntax-model.html#%28tech._base._phase%29), if it is not yet [instantiate](eval-model.html#%28tech._instantiate%29)d. The current [module name resolver](#%28tech._module._name._resolver%29) may load a module declaration to resolve mod (see [current-module-name-resolver](#%28def._%28%28quote._~23~25kernel%29._current-module-name-resolver%29%29)); the path is resolved relative to [current-load-relative-directory](eval.html#%28def._%28%28quote._~23~25kernel%29._current-load-relative-directory%29%29) and/or [current-directory](Filesystem.html#%28def._%28%28quote._~23~25kernel%29._current-directory%29%29). Beware that concurrent [dynamic-require](#%28def._%28%28quote._~23~25kernel%29._dynamic-require%29%29)s in namespaces that share a [module registry](syntax-model.html#%28tech._module._registry%29) can create race conditions; see also [namespace-call-with-registry-lock](Namespaces.html#%28def._%28%28quote._~23~25kernel%29._namespace-call-with-registry-lock%29%29).


# 13.11 Cryptographic Hashing
If provided is #f, then the result is [#<void>](https://plt.cs.northwestern.edu/new-snapshots/new-snapshots/doc/local-redirect/index.html?doc=guide&rel=void_undefined.html&version=8.18.0.13), and the module is not [visit](syntax-model.html#%28tech._visit%29)ed (see [Module Expansion, Phases, and Visits](syntax-model.html#%28part._mod-parse%29)) or even made [available](eval-model.html#%28tech._available%29) (for on-demand [visits](syntax-model.html#%28tech._visit%29)) in phases above the [base phase](syntax-model.html#%28tech._base._phase%29).
Examples:
> ```racket
> > ( module a racket/base ( displayln "hello" ) )
> > ( dynamic-require ' ' a #f )
> hello
> ```
> > > The double quoted ''a evaluates to the root-module-path 'a (see the grammar for [require](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29)). Using 'a for mod won’t work, because that evaluates to root-module-path a, and the example is not a module installed in a collection. Using a won’t work, because a is an undefined variable.
> > >
> > > Declaring ([module](module.html#%28form._%28%28quote._~23~25kernel%29._module%29%29) a ....) within another module, instead of in the read-eval-print loop, would create a submodule. In that case, ([dynamic-require](#%28def._%28%28quote._~23~25kernel%29._dynamic-require%29%29) ''a #f) would not access the module, because ''a does not refer to a submodule.


# 13.11 Cryptographic Hashing
When provided is a symbol, the value of the module’s export with the given name is returned, and still the module is not [visit](syntax-model.html#%28tech._visit%29)ed or made [available](eval-model.html#%28tech._available%29) in higher phases.
Examples:
> ```racket
> > ( module b racket/base ( provide dessert ) ( define dessert "gulab jamun" ) )
> > ( dynamic-require ' ' b ' dessert )
> "gulab jamun"
> ```
If the module exports provided as syntax, then syntax-thunk is called if it is a procedure, and its result is the result of the [dynamic-require](#%28def._%28%28quote._~23~25kernel%29._dynamic-require%29%29) call. If syntax-thunk is 'eval, a use of the binding is expanded and evaluated in a fresh namespace to which the module is attached, which means that the module is [visit](syntax-model.html#%28tech._visit%29)ed in the fresh namespace. The expanded syntax must return a single value.
Examples:
> ```racket
> > ( module c racket/base ( require ( for-syntax racket/base ) ) ( provide dessert2 ) ( define dessert "nanaimo bar" ) ( define-syntax dessert2 ( make-rename-transformer #' dessert ) ) )
> > ( dynamic-require ' ' c ' dessert2 )
> "nanaimo bar"
> ```


# 13.11 Cryptographic Hashing
If the module has no such exported variable or syntax, then fail-thunk is called, or the [exn:fail:contract](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3acontract%29%29) exception is raised if fail-thunk is 'error. If the variable named by provided is exported protected (see [Code Inspectors](modprotect.html)), then the [exn:fail:contract](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3acontract%29%29) exception is raised.
If provided is 0, then the module is [instantiate](eval-model.html#%28tech._instantiate%29)d but not [visit](syntax-model.html#%28tech._visit%29)ed, the same as when provided is #f. With 0, however, the module is made [available](eval-model.html#%28tech._available%29) in higher phases.
If provided is [#<void>](https://plt.cs.northwestern.edu/new-snapshots/new-snapshots/doc/local-redirect/index.html?doc=guide&rel=void_undefined.html&version=8.18.0.13), then the module is [visit](syntax-model.html#%28tech._visit%29)ed but not [instantiate](eval-model.html#%28tech._instantiate%29)d (see [Module Expansion, Phases, and Visits](syntax-model.html#%28part._mod-parse%29)), and the result is [#<void>](https://plt.cs.northwestern.edu/new-snapshots/new-snapshots/doc/local-redirect/index.html?doc=guide&rel=void_undefined.html&version=8.18.0.13).
More examples using different module-path grammar expressions are given below:
Example:
> ```racket
> > ( dynamic-require ' racket/base #f )
> ```
Example:
> ```racket
> > ( dynamic-require ( list ' lib "racket/base" ) #f )
> ```
Examples:


# 13.11 Cryptographic Hashing
> ```racket
> > ( module a racket/base ( module b racket/base ( provide inner-dessert ) ( define inner-dessert "tiramisu" ) ) )
> > ( dynamic-require ' ( submod ' a b ) ' inner-dessert )
> "tiramisu"
> ```
The last line in the above example could instead have been written as
Example:
> ```racket
> > ( dynamic-require ( ( lambda ( ) ( list ' submod ' ' a ' b ) ) ) ' inner-dessert )
> "tiramisu"
> ```
which is equivalent.
Changed in version 8.16.0.3 of package base: Added the syntax-thunk argument and changed to allow 'error for fail-thunk.
> ```
(parameter)	→
(-> or/c symbol? #f)


# 13.11 Cryptographic Hashing
```
Like dynamic-require, but in a phase that is 1 more than the namespace’s base phase.

Changed in version 8.16.0.3 of package base: Added the syntax-thunk argument and changed to allow 'error for fail-thunk.

> ```
(module-declared? mod [load?) → boolean?
   mod   :   ( or/c module-path? module-path-index?
> resolved-module-path? )

  load? : any/c = #f```

Returns #t if the module indicated by mod is [declare](eval-model.html#%28tech._declare%29)d (but not necessarily [instantiate](eval-model.html#%28tech._instantiate%29)d or [visit](syntax-model.html#%28tech._visit%29)ed) in the current namespace, #f otherwise.

If load? is #t and mod is not a [resolved module path](#%28tech._resolved._module._path%29), the module is loaded in the process of resolving mod (as for [dynamic-require](#%28def._%28%28quote._~23~25kernel%29._dynamic-require%29%29) and other functions). Checking for the declaration of a [submodule](eval-model.html#%28tech._submodule%29) does not trigger an exception if the submodule cannot be loaded because it does not exist, either within a root module that does exist or because the root module does not exist.

> ```
(parameter)	→
(-> or/c #f (vector/c module-path? symbol? any/c))
```


# 13.11 Cryptographic Hashing
Returns information intended to reflect the “language” of the implementation of mod. If mod is a resolved module path or load? is #f, the module named by mod must be declared (but not necessarily instantiated or visited) in the current namespace; otherwise, mod may be loaded (as for dynamic-require and other functions). The information returned by module  →  language-info is the same as would have been returned by module-compiled-language-info applied to the module’s implementation as compiled code.
A module can be declared by using dynamic-require.
Examples:
> ```racket
> > ( dynamic-require ' racket/dict ( void ) )
> > ( module  →  language-info ' racket/dict )
> #f
> ```
> ```
(module  →  imports mod)
   →    ( listof ( cons/c ( or/c exact-integer? #f )
> ( listof module-path-index? ) ) )
   mod   :   ( or/c module-path? module-path-index?
> resolved-module-path? )```
Like [module-compiled-imports](#%28def._%28%28quote._~23~25kernel%29._module-compiled-imports%29%29), but produces the imports of mod, which must be [declare](eval-model.html#%28tech._declare%29)d (but not necessarily [instantiate](eval-model.html#%28tech._instantiate%29)d or [visit](syntax-model.html#%28tech._visit%29)ed) in the current namespace. See [module->language-info](#%28def._%28%28quote._~23~25kernel%29._module-~3elanguage-info%29%29) for an example of declaring an existing module.
Examples:


# 13.11 Cryptographic Hashing
> ```racket
> > ( module banana racket/base ( require ( only-in racket/math pi ) ) ( provide peel ) ( define peel pi ) ( define bush ( * 2 pi ) ) )
> > ( module->imports ' ' banana )
> '((0 #<module-path-index:racket/base> #<module-path-index:racket/math>))
> ```
> ```
(module → exports mod [verbosity)
   →    (listof (cons/c phase+space? list?))
(listof (cons/c phase+space? list?))
   mod   :   ( or/c module-path? module-path-index?
> resolved-module-path? )
  verbosity : (or/c #f 'defined-names) = #f
```
(parameter)	→
(-> module banana racket/base (require (only-in racket/math pi)) (provide (rename-out [ peel wrapper ])) (define peel pi) (define bush (* 2 pi)))```

Like [module-compiled-indirect-exports](#%28def._%28%28quote._~23~25kernel%29._module-compiled-indirect-exports%29%29), but produces the indirect exports of mod, which must be [declare](eval-model.html#%28tech._declare%29)d (but not necessarily [instantiate](eval-model.html#%28tech._instantiate%29)d or [visit](syntax-model.html#%28tech._visit%29)ed) in the current namespace. See [module->language-info](#%28def._%28%28quote._~23~25kernel%29._module-~3elanguage-info%29%29) for an example of declaring an existing module.

Examples:

> ```racket
> > ( module banana racket/base ( require ( only-in racket/math pi ) ) ( provide peel ) ( define peel pi ) ( define bush ( * 2 pi ) ) )
> > ( module->indirect-exports ' ' banana )
> '((0 bush))
> ```

Added in version 6.5.0.5 of package base.

> ```
(parameter)	→
(-> or/c module-path? module-path-index?
    resolved-module-path?)
```


# 13.11 Cryptographic Hashing
Like module-compiled-realm, but produces the realm of mod, which must be declared (but not necessarily instantiated or visited) in the current namespace.
Added in version 8.4.0.2 of package base.
> ```
(module-predefined? mod)   →   boolean?
   mod   :   ( or/c module-path? module-path-index?
> resolved-module-path? )```
Reports whether mod refers to a module that is predefined for the running Racket instance. Predefined modules always have a symbolic resolved module path, and they may be predefined always or specifically within a particular executable (such as one created by raco exe or [create-embedding-executable](https://plt.cs.northwestern.edu/new-snapshots/new-snapshots/doc/local-redirect/index.html?doc=raco&rel=exe.html%23%2528def._%2528%2528lib._compiler%252Fembed..rkt%2529._create-embedding-executable%2529%2529&version=8.18.0.13)).


#### 14.4.4 Module Cache
The expander keeps a place-local module cache in order to save time while loading modules that have been previously declared.
> ```
(parameter)	→
```
(parameter)	→```

Returns #t if v is an [impersonator](#%28tech._impersonator%29) created by procedures like [impersonate-procedure](#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._impersonate-procedure%29%29) or [impersonate-struct](#%28def._%28%28quote._~23~25kernel%29._impersonate-struct%29%29), #f otherwise.

Programs and libraries generally should avoid [impersonator?](#%28def._%28%28quote._~23~25kernel%29._impersonator~3f%29%29) and treat impersonators the same as non-impersonator values. In rare cases, [impersonator?](#%28def._%28%28quote._~23~25kernel%29._impersonator~3f%29%29) may be needed to guard against redirection by an impersonator of an operation to an arbitrary procedure.

A limitation of [impersonator?](#%28def._%28%28quote._~23~25kernel%29._impersonator~3f%29%29) is that it does not recognize an [impersonator](#%28tech._impersonator%29) that is created by instantiating a structure type with the [prop:impersonator-of](#%28def._%28%28quote._~23~25kernel%29._prop~3aimpersonator-of%29%29) property. The limitation reflects how those impersonators cannot redirect structure access and mutation operations to arbitrary procedures.

> ```
(chaperone? v)  →  boolean?
  v : any/c
```
Returns #t if v is a chaperone, #f otherwise.


# 13.11 Cryptographic Hashing
Programs and libraries generally should avoid chaperone? for the same reason that they should avoid impersonator?. A true value for chaperone? implies a true value of impersonator?.
> ```
(impersonator-of? v1 v2)   →   boolean?
  v1 : any/c
  v2 : any/c```
Indicates whether v1 can be considered equivalent modulo impersonators to v2.
Any two values that are [eq?](Equality.html#%28def._%28%28quote._~23~25kernel%29._eq~3f%29%29) to one another are also [impersonator-of?](#%28def._%28%28quote._~23~25kernel%29._impersonator-of~3f%29%29). For values that include no impersonators, v1 and v2 are considered impersonators of each other if they are [equal?](Equality.html#%28def._%28%28quote._~23~25kernel%29._equal~3f%29%29).
If at least one of v1 or v2 is an impersonator:
-   If v1 impersonates v1\* then ([impersonator-of?](#%28def._%28%28quote._~23~25kernel%29._impersonator-of~3f%29%29) v1 v2) is #t if and only if ([impersonator-of?](#%28def._%28%28quote._~23~25kernel%29._impersonator-of~3f%29%29) v1\* v2) is #t.
-   If v2 is a non-interposing impersonator that impersonates v2\*, i.e., all of its interposition procedures are #f, then ([impersonator-of?](#%28def._%28%28quote._~23~25kernel%29._impersonator-of~3f%29%29) v1 v2) is #t if and only if ([impersonator-of?](#%28def._%28%28quote._~23~25kernel%29._impersonator-of~3f%29%29) v1 v2\*) is #t.


# 13.11 Cryptographic Hashing
-   When v2 is an impersonator constructed with at least one non-#f interposition procedure, but v1 is not an impersonator then ([impersonator-of?](#%28def._%28%28quote._~23~25kernel%29._impersonator-of~3f%29%29) v1 v2) is #f.
Otherwise, if neither v1 or v2 is an impersonator, but either of them contains an impersonator as a subpart (e.g., v1 is a list with an impersonator as one of its elements), then ([impersonator-of?](#%28def._%28%28quote._~23~25kernel%29._impersonator-of~3f%29%29) v1 v2) proceeds by comparing v1 and v2 recursively (as with [equal?](Equality.html#%28def._%28%28quote._~23~25kernel%29._equal~3f%29%29)), returning true if all subparts are [impersonator-of?](#%28def._%28%28quote._~23~25kernel%29._impersonator-of~3f%29%29).
Examples:
> ```racket
> > ( impersonator-of? ( impersonate-procedure add1 ( λ ( x ) x ) ) add1 )
> #t
> > ( impersonator-of? ( impersonate-procedure add1 ( λ ( x ) x ) ) sub1 )
> #f
> > ( impersonator-of? ( impersonate-procedure ( impersonate-procedure add1 ( λ ( x ) x ) ) ( λ ( x ) x ) ) add1 )
> #t
> > ( impersonator-of? ( impersonate-procedure add1 ( λ ( x ) x ) ) ( impersonate-procedure add1 #f ) )
> #t
> > ( impersonator-of? ( impersonate-procedure add1 ( λ ( x ) x ) ) ( impersonate-procedure add1 ( λ ( x ) x ) ) )
> #f
> > ( impersonator-of? ( list 1 2 ) ( list 1 2 ) )
> #t
> > ( impersonator-of? ( list ( impersonate-procedure add1 ( λ ( x ) x ) ) sub1 ) ( list add1 sub1 ) )
> #t
> ```
> ```
(chaperone-of? v1 v2)  →  boolean?
  v1 : any/c
  v2 : any/c


# 13.11 Cryptographic Hashing
```
Indicates whether v1 can be considered equivalent modulo chaperones to v2.

For values that include no chaperones or other impersonators, v1 and v2 can be considered chaperones of each other if they are equal-always?, which requires that they are equal? except that corresponding mutable vectors, boxes, hash tables, strings, byte strings, mutable pairs, and mutable structures within v1 and v2 must be eq?.

Otherwise, chaperones and other impersonators within v2 must be intact within v1 analogous to way that impersonator-of? requires that impersonators are preserved. Furthermore, v1 must not have any non-chaperone impersonators whose corresponding value in v2 is not the same impersonator. Note that chaperone-of? implies impersonator-of?, but not vice-versa.

> ```
(impersonator-ephemeron v)   →   ephemeron?
  v : any/c```

Produces an [ephemeron](ephemerons.html#%28tech._ephemeron%29) that can be used to connect the reachability of v (in the sense of garbage collection; see [Garbage Collection](eval-model.html#%28part._gc-model%29)) with the reachability of any value for which v is an [impersonator](#%28tech._impersonator%29). That is, the value v will be considered reachable as long as the result ephemeron is reachable in addition to any value that v impersonates (including itself).

In the terminology of [ephemerons](ephemerons.html#%28tech._ephemeron%29), v is the value of the ephemeron and all of the values that v impersonates are keys.

> ```
(procedure-impersonator*? v)  →  boolean?
  v : any/c
```


# 13.11 Cryptographic Hashing
Returns #t for any procedure impersonator that either was produced by impersonate-procedure* or chaperone-procedure*, or is an impersonator/chaperone of a value that was created with impersonate-procedure* or chaperone-procedure* (possibly transitively).


#### 14.5.1 Impersonator Constructors
> ```
(impersonate-procedure proc
    wrapper-proc
    prop
    prop-val ...
    ...)
   →   (and/c procedure? impersonator?)
  proc : procedure?
  wrapper-proc : (or/c procedure? #f)
  prop : impersonator-property?
  prop-val : any/c```
Returns an impersonator procedure that has the same arity, name, and other attributes as proc. When the impersonator procedure is applied, the arguments are first passed to wrapper-proc (when it is not #f), and then the results from wrapper-proc are passed to proc. The wrapper-proc can also supply a procedure that processes the results of proc.
The arity of wrapper-proc must include the arity of proc. The allowed keyword arguments of wrapper-proc must be a superset of the allowed keywords of proc. The required keyword arguments of wrapper-proc must be a subset of the required keywords of proc.
For applications without keywords, the result of wrapper-proc must be at least the same number of values as supplied to it. Additional results can be supplied—before the values that correspond to the supplied values—in the following pattern:
-   An optional procedure, result-wrapper-proc, which will be applied to the results of proc; followed by
-   any number of repetitions of 'mark key val (i.e., three values), where the call proc is wrapped to install a [continuation mark](eval-model.html#%28tech._continuation._mark%29) key and val.


# 13.11 Cryptographic Hashing
If result-wrapper-proc is produced, it must be a procedure that accepts as many results as produced by proc; it must return the same number of results. If result-wrapper-proc is not supplied, then proc is called in [tail position](eval-model.html#%28tech._tail._position%29) with respect to the call to the impersonator.
For applications that include keyword arguments, wrapper-proc must return an additional value before any other values but after result-wrapper-proc and 'mark key val sequences (if any). The additional value must be a list of replacements for the keyword arguments that were supplied to the impersonator (i.e., not counting optional arguments that were not supplied). The arguments must be ordered according to the sorted order of the supplied arguments’ keywords.
If wrapper-proc is #f, then applying the resulting impersonator is the same as applying proc. If wrapper-proc is #f and no prop is provided, then proc is returned and is not impersonated.
Pairs of prop and prop-val (the number of arguments to [impersonate-procedure](#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._impersonate-procedure%29%29) must be even) add impersonator properties or override impersonator-property values of proc.


# 13.11 Cryptographic Hashing
If any prop is [impersonator-prop:application-mark](#%28def._%28%28quote._~23~25kernel%29._impersonator-prop~3aapplication-mark%29%29) and if the associated prop-val is a pair, then the call to proc is wrapped with [with-continuation-mark](wcm.html#%28form._%28%28quote._~23~25kernel%29._with-continuation-mark%29%29) using ([car](pairs.html#%28def._%28%28quote._~23~25kernel%29._car%29%29) prop-val) as the mark key and ([cdr](pairs.html#%28def._%28%28quote._~23~25kernel%29._cdr%29%29) prop-val) as the mark value. In addition, if the immediate continuation frame of the call to the impersonated procedure includes a value for ([car](pairs.html#%28def._%28%28quote._~23~25kernel%29._car%29%29) prop-val)—that is, if [call-with-immediate-continuation-mark](contmarks.html#%28def._%28%28quote._~23~25kernel%29._call-with-immediate-continuation-mark%29%29) would produce a value for ([car](pairs.html#%28def._%28%28quote._~23~25kernel%29._car%29%29) prop-val) in the call’s continuation—then the value is also installed as an immediate value for ([car](pairs.html#%28def._%28%28quote._~23~25kernel%29._car%29%29) prop-val) as a mark during the call to wrapper-proc (which allows tail-calls of impersonators with respect to wrapping impersonators to be detected within wrapper-proc).
Changed in version 6.3.0.5 of package base: Added support for 'mark key val results from wrapper-proc.
Examples:


# 13.11 Cryptographic Hashing
> ```racket
> > ( define ( add15 x ) ( + x 15 ) )
> > ( define add15+print ( impersonate-procedure add15 ( λ ( x ) ( printf "called with ~s\n" x ) ( values ( λ ( res ) ( printf "returned ~s\n" res ) res ) x ) ) ) )
> > ( add15 27 )
> 42
> > ( add15+print 27 )
> called with 27 returned 42
> 42
> > ( define-values ( imp-prop:p1 imp-prop:p1? imp-prop:p1-get ) ( make-impersonator-property ' imp-prop:p1 ) )
> > ( define-values ( imp-prop:p2 imp-prop:p2? imp-prop:p2-get ) ( make-impersonator-property ' imp-prop:p2 ) )
> > ( define add15.2 ( impersonate-procedure add15 #f imp-prop:p1 11 ) )
> > ( add15.2 2 )
> 17
> > ( imp-prop:p1? add15.2 )
> #t
> > ( imp-prop:p1-get add15.2 )
> 11
> > ( imp-prop:p2? add15.2 )
> #f
> > ( define add15.3 ( impersonate-procedure add15.2 #f imp-prop:p2 13 ) )
> > ( add15.3 3 )
> 18
> > ( imp-prop:p1? add15.3 )
> #t
> > ( imp-prop:p1-get add15.3 )
> 11
> > ( imp-prop:p2? add15.3 )
> #t
> > ( imp-prop:p2-get add15.3 )
> 13
> > ( define add15.4 ( impersonate-procedure add15.3 #f imp-prop:p1 101 ) )
> > ( add15.4 4 )
> 19
> > ( imp-prop:p1? add15.4 )
> #t
> > ( imp-prop:p1-get add15.4 )
> 101
> > ( imp-prop:p2? add15.4 )
> #t
> > ( imp-prop:p2-get add15.4 )
> 13
> ```
> ```
(impersonate-procedure* proc
    wrapper-proc
    prop
    prop-val ...
    ...)
  →  (and/c procedure? impersonator?)
  proc : procedure?
  wrapper-proc : (or/c procedure? #f)
  prop : impersonator-property?
  prop-val : any/c


# 13.11 Cryptographic Hashing
```
Like impersonate-procedure, except that wrapper-proc receives an additional argument before all other arguments. The additional argument is the procedure orig-proc that was originally applied.

If the result of impersonate-procedure* is applied directly, then orig-proc is that result. If the result is further impersonated before being applied, however, orig-proc is the further impersonator.

An orig-proc argument might be useful so that wrapper-proc can extract impersonator properties that are overridden by further impersonators, for example.

Added in version 6.1.1.5 of package base.

> ```
(impersonate-struct v
   [ struct-type]
    orig-proc
    redirect-proc ...
    ...
    prop
    prop-val ...
    ...)    →    any/c

  v : any/c
  struct-type : struct-type? = unspecified
   orig-proc   :   ( or/c struct-accessor-procedure?
> struct-mutator-procedure?
> struct-type-property-accessor-procedure? )

  redirect-proc : (or/c procedure? #f)
  prop : impersonator-property?
  prop-val : any/c```

Returns an impersonator of v, which redirects certain operations on the impersonated value. The orig-procs indicate the operations to redirect, and the corresponding redirect-procs supply the redirections. The optional struct-type argument, when provided, acts as a witness for the representation of v, which must be an instance of struct-type.

The protocol for a redirect-proc depends on the corresponding orig-proc, where self refers to the value to which orig-proc is originally applied:

-   A structure-field accessor: redirect-proc must accept two arguments, self and the value field-v that orig-proc produces for v; it must return a replacement for field-v. The corresponding field must not be immutable, and either the field’s structure type must be accessible via the current [inspector](inspectors.html#%28tech._inspector%29) or one of the other orig-procs must be a structure-field mutator for the same field.

-   A structure-field mutator: redirect-proc must accept two arguments, self and the value field-v supplied to the mutator; it must return a replacement for field-v to be propagated to orig-proc and v.

-   A property accessor: redirect-proc uses the same protocol as for a structure-field accessor. The accessor’s property must have been created with 'can-impersonate as the second argument to [make-struct-type-property](structprops.html#%28def._%28%28quote._~23~25kernel%29._make-struct-type-property%29%29).

When a redirect-proc is #f, the corresponding orig-proc is unaffected. Supplying #f for a redirect-proc is useful to allow its orig-proc to act as a “witness” of v’s representation and enable the addition of props.

Pairs of prop and prop-val (the number of arguments to [impersonate-struct](#%28def._%28%28quote._~23~25kernel%29._impersonate-struct%29%29) must be even if struct-type is provided, odd otherwise) add impersonator properties or override impersonator-property values of v.

Each orig-proc must indicate a distinct operation. If no struct-type and no orig-procs are supplied, then no props must be supplied. If orig-procs are supplied only with #f redirect-procs and no props are supplied, then v is returned and is not impersonated.

If any orig-proc is itself an impersonator, then a use of the accessor or mutator that orig-proc impersonates is redirected for the resulting impersonated structure to use orig-proc on v before redirect-proc (in the case of accessor) or after redirect-proc (in the case of a mutator).

Changed in version 6.1.1.2 of package base: Changed first argument to an accessor or mutator redirect-proc from v to self.
Changed in version 6.1.1.8: Added optional struct-type argument.

> ```
(impersonate-vector vec
    ref-proc
    set-proc
    prop
    prop-val ...
    ...)

  →  (and/c vector? impersonator?)
  vec : (and/c vector? (not/c immutable?))
  ref-proc : (or/c (vector? exact-nonnegative-integer? any/c .  →  . any/c) #f)
  set-proc : (or/c (vector? exact-nonnegative-integer? any/c .  →  . any/c) #f)
  prop : impersonator-property?
  prop-val : any/c
```


# 13.11 Cryptographic Hashing
Returns an impersonator of vec, which redirects the vector-ref and vector-set! operations.
The ref-proc and set-proc arguments must either both be procedures or both be #f. If they are #f then impersonate-vector does not interpose on vec, but still allows attaching impersonator properties.
If ref-proc is a procedure it must accept vec, an index passed to vector-ref, and the value that vector-ref on vec produces for the given index; it must produce a replacement for the value, which is the result of vector-ref on the impersonator.
If set-proc is a procedure it must accept vec, an index passed to vector-set!, and the value passed to vector-set!; it must produce a replacement for the value, which is used with vector-set! on the original vec to install the value.
Pairs of prop and prop-val (the number of arguments to impersonate-vector must be odd) add impersonator properties or override impersonator-property values of vec.
Changed in version 6.9.0.2 of package base: Added non-interposing vector impersonators.
> ```
(impersonate-vector* vec
    ref-proc
    set-proc
    prop
    prop-val ...
    ...)
   →   (and/c vector? impersonator?)
  vec : (and/c vector? (not/c immutable?))
  ref-proc : (or/c (vector? vector? exact-nonnegative-integer? any/c .  →  . any/c) #f)
  set-proc : (or/c (vector? vector? exact-nonnegative-integer? any/c .  →  . any/c) #f)
  prop : impersonator-property?
  prop-val : any/c```


# 13.11 Cryptographic Hashing
Like [impersonate-vector](#%28def._%28%28quote._~23~25kernel%29._impersonate-vector%29%29), except that ref-proc and set-proc each receive an additional vector as argument before other arguments. The additional argument is the original impersonated vector, access to which triggered interposition in the first place.
The additional vector argument might be useful so that ref-proc or set-proc can extract impersonator properties that are overridden by further impersonators, for example.
Added in version 6.9.0.2 of package base.
> ```
(impersonate-box box
    unbox-proc
    set-proc
    prop
    prop-val ...
    ...)    →    (and/c box? impersonator?)
  box : (and/c box? (not/c immutable?))
  unbox-proc : (box? any/c .  →  . any/c)
  set-proc : (box? any/c .  →  . any/c)
  prop : impersonator-property?
  prop-val : any/c


# 13.11 Cryptographic Hashing
```
Returns an impersonator of box, which redirects the unbox and set-box! operations.

The unbox-proc must accept box and the value that unbox produces on box; it must produce a replacement value, which is the result of unbox on the impersonator.

The set-proc must accept box and the value passed to set-box!; it must produce a replacement value, which is used with set-box! on the original box to install the value.

Pairs of prop and prop-val (the number of arguments to impersonate-box must be odd) add impersonator properties or override impersonator-property values of box.

> ```
(impersonate-hash hash
    ref-proc
    set-proc
    remove-proc
    key-proc
   [ clear-proc
    equal-key-proc]
    prop
    prop-val ...
    ...)    →    (and/c hash? impersonator?)

  hash : (and/c hash? (not/c immutable?))
   ref-proc   :   ( hash? any/c .  →  . ( values
> any/c
> ( hash? any/c any/c .  →  . any/c ) ) )

  set-proc : (hash? any/c any/c .  →  . (values any/c any/c))
  remove-proc : (hash? any/c .  →  . any/c)
  key-proc : (hash? any/c .  →  . any/c)
  clear-proc : (or/c #f (hash? .  →  . any)) = #f
  equal-key-proc : (or/c #f (hash? any/c .  →  . any/c)) = #f
  prop : impersonator-property?
  prop-val : any/c```

Returns an impersonator of hash, which redirects the [hash-ref](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-ref%29%29), [hash-set!](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-set%21%29%29) or [hash-set](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-set%29%29) (as applicable), [hash-remove](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-remove%29%29) or [hash-remove!](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-remove%21%29%29) (as applicable), [hash-clear](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-clear%29%29) or [hash-clear!](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-clear%21%29%29) (as applicable and if clear-proc is not #f) operations. When [hash-set](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-set%29%29), [hash-remove](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-remove%29%29) or [hash-clear](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-clear%29%29) is used on an impersonator of a hash table, the result is an impersonator with the same redirecting procedures. In addition, operations like [hash-iterate-key](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-iterate-key%29%29) or [hash-map](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-map%29%29), which extract keys from the table, use key-proc to replace keys extracted from the table. Operations like [hash-iterate-value](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-iterate-value%29%29) or [hash-values](hashtables.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._hash-values%29%29) implicitly use [hash-ref](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-ref%29%29) and therefore redirect through ref-proc. The [hash-ref-key](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-ref-key%29%29) operation uses both ref-proc and key-proc, the former to lookup the requested key and the latter to extract it.

The ref-proc must accept hash and a key passed to [hash-ref](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-ref%29%29). It must return a replacement key as well as a procedure. The returned procedure is called only if the returned key is found in hash via [hash-ref](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-ref%29%29), in which case the procedure is called with hash, the previously returned key, and the found value. The returned procedure must itself return a replacement for the found value. The returned procedure is ignored by [hash-ref-key](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-ref-key%29%29).

The set-proc must accept hash, a key passed to [hash-set!](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-set%21%29%29) or [hash-set](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-set%29%29), and the value passed to [hash-set!](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-set%21%29%29) or [hash-set](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-set%29%29); it must produce two values: a replacement for the key and a replacement for the value. The returned key and value are used with [hash-set!](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-set%21%29%29) or [hash-set](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-set%29%29) on the original hash to install the value.

The remove-proc must accept hash and a key passed to [hash-remove!](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-remove%21%29%29) or [hash-remove](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-remove%29%29); it must produce a replacement for the key, which is used with [hash-remove!](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-remove%21%29%29) or [hash-remove](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-remove%29%29) on the original hash to remove any mapping using the (impersonator-replaced) key.

The key-proc must accept hash and a key that has been extracted from hash (by [hash-ref-key](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-ref-key%29%29), [hash-iterate-key](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-iterate-key%29%29), or other operations that use [hash-iterate-key](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-iterate-key%29%29) internally); it must produce a replacement for the key, which is then reported as a key extracted from the table.

If clear-proc is not #f, it must accept hash as an argument, and its result is ignored. The fact that clear-proc returns (as opposed to raising an exception or otherwise escaping) grants the capability to remove all keys from hash. If clear-proc is #f, then [hash-clear](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-clear%29%29) or [hash-clear!](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-clear%21%29%29) on the impersonator is implemented using [hash-iterate-key](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-iterate-key%29%29) and [hash-remove](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-remove%29%29) or [hash-remove!](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-remove%21%29%29).

If equal-key-proc is not #f, it effectively interposes on calls to [equal?](Equality.html#%28def._%28%28quote._~23~25kernel%29._equal~3f%29%29), [equal-hash-code](Equality.html#%28def._%28%28quote._~23~25kernel%29._equal-hash-code%29%29), and [equal-secondary-hash-code](Equality.html#%28def._%28%28quote._~23~25kernel%29._equal-secondary-hash-code%29%29) for the keys of hash. The equal-key-proc must accept as its arguments hash and a key that is either mapped by hash or passed to [hash-ref](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-ref%29%29), etc., where the latter has potentially been adjusted by the corresponding ref-proc, etc. The result is a value that is passed to [equal?](Equality.html#%28def._%28%28quote._~23~25kernel%29._equal~3f%29%29), [equal-hash-code](Equality.html#%28def._%28%28quote._~23~25kernel%29._equal-hash-code%29%29), and [equal-secondary-hash-code](Equality.html#%28def._%28%28quote._~23~25kernel%29._equal-secondary-hash-code%29%29) as needed to hash and compare keys. In the case of [hash-set!](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-set%21%29%29) or [hash-set](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-set%29%29), the key that is passed to equal-key-proc is the one stored in the hash table for future lookup.

The [hash-iterate-value](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-iterate-value%29%29), [hash-map](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-map%29%29), or [hash-for-each](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-for-each%29%29) functions use a combination of [hash-iterate-key](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-iterate-key%29%29) and [hash-ref](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-ref%29%29). If a key produced by key-proc does not yield a value through [hash-ref](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-ref%29%29), then the [exn:fail:contract](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3acontract%29%29) exception is raised.

Pairs of prop and prop-val add impersonator properties or override impersonator-property values of hash.

In the case of an immutable hash table, two impersonated hash tables count as “the same value” (for purposes of [impersonator-of?](#%28def._%28%28quote._~23~25kernel%29._impersonator-of~3f%29%29)) when their redirection procedures were originally attached to a hash table by the same call to [impersonate-hash](#%28def._%28%28quote._~23~25kernel%29._impersonate-hash%29%29) or [chaperone-hash](#%28def._%28%28quote._~23~25kernel%29._chaperone-hash%29%29) (and potentially propagated by [hash-set](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-set%29%29), [hash-remove](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-remove%29%29), or [hash-clear](hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash-clear%29%29)), as long as the content of the first hash table is [impersonator-of?](#%28def._%28%28quote._~23~25kernel%29._impersonator-of~3f%29%29) of the second hash table.

Changed in version 6.3.0.11 of package base: Added the equal-key-proc argument.

> ```
(impersonate-channel channel
    get-proc
    put-proc
    prop
    prop-val ...
    ...)

  →  (and/c channel? impersonator?)
  channel : channel?
  get-proc : (channel? .  →  . (values channel? (any/c .  →  . any/c)))
  put-proc : (channel? any/c .  →  . any/c)
  prop : impersonator-property?
  prop-val : any/c
```


# 13.11 Cryptographic Hashing
Returns an impersonator of channel, which redirects the channel-get and channel-put operations.
The get-proc generator is called on channel-get or any other operation that fetches results from the channel (such as a sync on the channel). The get-proc must return two values: a channel that is an impersonator of channel, and a procedure that is used to check the channel’s contents.
The put-proc must accept channel and the value passed to channel-put; it must produce a replacement value, which is used with channel-put on the original channel to send the value over the channel.
Pairs of prop and prop-val (the number of arguments to impersonate-channel must be odd) add impersonator properties or override impersonator-property values of channel.
> ```
(impersonate-prompt-tag prompt-tag
    handle-proc
    abort-proc
   [ cc-guard-proc
    callcc-impersonate-proc]
    prop
    prop-val ...
    ...)
   →   (and/c continuation-prompt-tag? impersonator?)
  prompt-tag : continuation-prompt-tag?
  handle-proc : procedure?
  abort-proc : procedure?
  cc-guard-proc : procedure? = values
   callcc-impersonate-proc   :   (procedure? .  →  . procedure?)
      =   (lambda (p) p)
  prop : impersonator-property?
  prop-val : any/c```
Returns an impersonator of prompt-tag, which redirects the [call-with-continuation-prompt](cont.html#%28def._%28%28quote._~23~25kernel%29._call-with-continuation-prompt%29%29) and [abort-current-continuation](cont.html#%28def._%28%28quote._~23~25kernel%29._abort-current-continuation%29%29) operations.


# 13.11 Cryptographic Hashing
The handle-proc must accept the values that the handler of a continuation prompt would take and it must produce replacement values, which will be passed to the handler.
The abort-proc must accept the values passed to [abort-current-continuation](cont.html#%28def._%28%28quote._~23~25kernel%29._abort-current-continuation%29%29); it must produce replacement values, which are aborted to the appropriate prompt.
The cc-guard-proc must accept the values produced by [call-with-continuation-prompt](cont.html#%28def._%28%28quote._~23~25kernel%29._call-with-continuation-prompt%29%29) in the case that a non-composable continuation is applied to replace the continuation that is delimited by the prompt, but only if [abort-current-continuation](cont.html#%28def._%28%28quote._~23~25kernel%29._abort-current-continuation%29%29) is not later used to abort the continuation delimited by the prompt (in which case abort-proc is used).


# 13.11 Cryptographic Hashing
The callcc-impersonate-proc must accept a procedure that guards the result of a continuation captured by [call-with-current-continuation](cont.html#%28def._%28%28quote._~23~25kernel%29._call-with-current-continuation%29%29) with the impersonated prompt tag. The callcc-impersonate-proc is applied (under a [continuation barrier](eval-model.html#%28tech._continuation._barrier%29)) when the captured continuation is applied to refine a guard function (initially [values](values.html#%28def._%28%28quote._~23~25kernel%29._values%29%29)) that is specific to the delimiting prompt; this prompt-specific guard is ultimately composed with any cc-guard-proc that is in effect at the delimiting prompt, and it is not used in the same case that a cc-guard-proc is not used (i.e., when [abort-current-continuation](cont.html#%28def._%28%28quote._~23~25kernel%29._abort-current-continuation%29%29) is used to abort to the prompt). In the special case where the delimiting prompt at application time is a thread’s built-in initial prompt, callcc-impersonate-proc is ignored (partly on the grounds that the initial prompt’s result is ignored).
Pairs of prop and prop-val (the number of arguments to [impersonate-prompt-tag](#%28def._%28%28quote._~23~25kernel%29._impersonate-prompt-tag%29%29) must be odd) add impersonator properties or override impersonator-property values of prompt-tag.
Examples:


# 13.11 Cryptographic Hashing
> ```racket
> > ( define tag ( impersonate-prompt-tag ( make-continuation-prompt-tag ) ( lambda ( n ) ( * n 2 ) ) ( lambda ( n ) ( + n 1 ) ) ) )
> > ( call-with-continuation-prompt ( lambda ( ) ( abort-current-continuation tag 5 ) ) tag ( lambda ( n ) n ) )
> 12
> ```
> ```
(impersonate-continuation-mark-key key
    get-proc
    set-proc
    prop
    prop-val ...
    ...)
  →  (and/c continuation-mark? impersonator?)
  key : continuation-mark-key?
  get-proc : procedure?
  set-proc : procedure?
  prop : impersonator-property?
  prop-val : any/c
```
(recursively)	→
(-> the number of arguments to impersonate-continuation-mark-key must be odd)```

Like [impersonate-procedure](#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._impersonate-procedure%29%29), but for each value supplied to wrapper-proc, the corresponding result must be the same or a chaperone of (in the sense of [chaperone-of?](#%28def._%28%28quote._~23~25kernel%29._chaperone-of~3f%29%29)) the supplied value. The additional result, if any, that precedes the chaperoned values must be a procedure that accepts as many results as produced by proc; it must return the same number of results, each of which is the same or a chaperone of the corresponding original result.

For applications that include keyword arguments, wrapper-proc must return an additional value before any other values but after the result-chaperoning procedure (if any). The additional value must be a list of chaperones of the keyword arguments that were supplied to the chaperone procedure (i.e., not counting optional arguments that were not supplied). The arguments must be ordered according to the sorted order of the supplied arguments’ keywords.

> ```
(chaperone-procedure* proc
    wrapper-proc
    prop
    prop-val ...
    ...)

  →  (and/c procedure? chaperone?)
  proc : procedure?
  wrapper-proc : (or/c procedure? #f)
  prop : impersonator-property?
  prop-val : any/c
```


# 13.11 Cryptographic Hashing
Like chaperone-procedure, but wrapper-proc receives an extra argument as with impersonate-procedure*.
Added in version 6.1.1.5 of package base.
> ```
(chaperone-struct v
   [ struct-type]
    orig-proc
    redirect-proc ...
    ...
    prop
    prop-val ...
    ...)    →    any/c
  v : any/c
  struct-type : struct-type? = unspecified
   orig-proc   :   ( or/c struct-accessor-procedure?
> struct-mutator-procedure?
> struct-type-property-accessor-procedure?
> ( lambda ( proc )
> ( eq? proc struct-info ) ) )
  redirect-proc : (or/c procedure? #f)
  prop : impersonator-property?
  prop-val : any/c```
Like [impersonate-struct](#%28def._%28%28quote._~23~25kernel%29._impersonate-struct%29%29), but with the following refinements, where self refers to the value to which a orig-proc is originally applied:
-   With a structure-field accessor as orig-proc, redirect-proc must accept two arguments, self and the value field-v that orig-proc produces for v; it must return a chaperone of field-v. The corresponding field may be immutable.
-   With structure-field mutator as orig-proc, redirect-proc must accept two arguments, self and the value field-v supplied to the mutator; it must return a chaperone of field-v to be propagated to orig-proc and v.
-   A property accessor can be supplied as orig-proc, and the property need not have been created with 'can-impersonate. The corresponding redirect-proc uses the same protocol as for a structure-field accessor.


# 13.11 Cryptographic Hashing
-   With [struct-info](inspectors.html#%28def._%28%28quote._~23~25kernel%29._struct-info%29%29) as orig-proc, the corresponding redirect-proc must accept two values, which are the results of [struct-info](inspectors.html#%28def._%28%28quote._~23~25kernel%29._struct-info%29%29) on v; it must return each values or a chaperone of each value. The redirect-proc is not called if [struct-info](inspectors.html#%28def._%28%28quote._~23~25kernel%29._struct-info%29%29) would return #f as its first argument. An orig-proc can be [struct-info](inspectors.html#%28def._%28%28quote._~23~25kernel%29._struct-info%29%29) only if struct-type or some other orig-proc is supplied.
-   Any accessor or mutator orig-proc that is an [impersonator](#%28tech._impersonator%29) must be specifically a [chaperone](#%28tech._chaperone%29).
Supplying a property accessor for orig-proc enables prop arguments, the same as supplying an accessor, mutator, or structure type.
Changed in version 6.1.1.2 of package base: Changed first argument to an accessor or mutator redirect-proc from v to self.
Changed in version 6.1.1.8: Added optional struct-type argument.
> ```
(chaperone-vector vec
    ref-proc
    set-proc
    prop
    prop-val ...
    ...)    →    (and/c vector? chaperone?)
  vec : vector?
  ref-proc : (or/c (vector? exact-nonnegative-integer? any/c .  →  . any/c) #f)
  set-proc : (or/c (vector? exact-nonnegative-integer? any/c .  →  . any/c) #f)
  prop : impersonator-property?
  prop-val : any/c


# 13.11 Cryptographic Hashing
```
Like impersonate-vector, but with support for immutable vectors. The ref-proc procedure must produce the same value or a chaperone of the original value, and set-proc must produce the value that is given or a chaperone of the value. The set-proc will not be used if vec is immutable.

> ```
(chaperone-vector* vec
    ref-proc
    set-proc
    prop
    prop-val ...
    ...)    →    (and/c vector? chaperone?)

  vec : vector?
  ref-proc : (or/c (vector? vector? exact-nonnegative-integer? any/c .  →  . any/c) #f)
  set-proc : (or/c (vector? vector? exact-nonnegative-integer? any/c .  →  . any/c) #f)
  prop : impersonator-property?
  prop-val : any/c```

Like [chaperone-vector](#%28def._%28%28quote._~23~25kernel%29._chaperone-vector%29%29), but ref-proc and set-proc receive an extra argument as with [impersonate-vector*](#%28def._%28%28quote._~23~25kernel%29._impersonate-vector%2A%29%29).

Added in version 6.9.0.2 of package base.

> ```
(chaperone-box box
    unbox-proc
    set-proc
    prop
    prop-val ...
    ...)    →    (and/c box? chaperone?)

  box : box?
  unbox-proc : (box? any/c .  →  . any/c)
  set-proc : (box? any/c .  →  . any/c)
  prop : impersonator-property?
  prop-val : any/c
```
Like impersonate-box, but with support for immutable boxes. The unbox-proc procedure must produce the same value or a chaperone of the original value, and set-proc must produce the same value or a chaperone of the value that it is given. The set-proc will not be used if box is immutable.


# 13.11 Cryptographic Hashing
> ```
(chaperone-hash hash
    ref-proc
    set-proc
    remove-proc
    key-proc
   [ clear-proc
    equal-key-proc]
    prop
    prop-val ...
    ...)    →    (and/c hash? chaperone?)
  hash : hash?
   ref-proc   :   ( hash? any/c .  →  . ( values
> any/c
> ( hash? any/c any/c .  →  . any/c ) ) )
  set-proc : (hash? any/c any/c .  →  . (values any/c any/c))
  remove-proc : (hash? any/c .  →  . any/c)
  key-proc : (hash? any/c .  →  . any/c)
  clear-proc : (or/c #f (hash? .  →  . any)) = #f
  equal-key-proc : (or/c #f (hash? any/c .  →  . any/c)) = #f
  prop : impersonator-property?
  prop-val : any/c```
Like [impersonate-hash](#%28def._%28%28quote._~23~25kernel%29._impersonate-hash%29%29), but with constraints on the given functions and support for immutable hashes. The ref-proc procedure must return a found value or a chaperone of the value. The set-proc procedure must produce two values: the key that it is given or a chaperone of the key and the value that it is given or a chaperone of the value. The remove-proc, key-proc, and equal-key-proc procedures must produce the given key or a chaperone of the key.
Changed in version 6.3.0.11 of package base: Added the equal-key-proc argument.
> ```
(chaperone-struct-type struct-type
    struct-info-proc
    make-constructor-proc
    guard-proc
    prop
    prop-val ...
    ...)


# 13.11 Cryptographic Hashing
  →  (and/c struct-type? chaperone?)
  struct-type : struct-type?
  struct-info-proc : procedure?
  make-constructor-proc : (procedure? .  →  . procedure?)
  guard-proc : procedure?
  prop : impersonator-property?
  prop-val : any/c
```
Returns a chaperoned value like struct-type, but with struct-type-info and struct-type-make-constructor operations on the chaperoned structure type redirected. In addition, when a new structure type is created as a subtype of the chaperoned structure type, guard-proc is interposed as an extra guard on creation of instances of the subtype.

The struct-info-proc must accept 8 arguments—the result of struct-type-info on struct-type. It must return 8 values, where each is the same or a chaperone of the corresponding argument. The 8 values are used as the results of struct-type-info for the chaperoned structure type.

The make-constructor-proc must accept a single procedure argument, which is a constructor produced by struct-type-make-constructor on struct-type. It must return the same or a chaperone of the procedure, which is used as the result of struct-type-make-constructor on the chaperoned structure type.

The guard-proc is like a guard argument to make-struct-type: it must accept one more argument than a constructor for struct-type, where the last argument is the name the name of the instantiated structure type. It must return the number of values needed by the constructor (i.e. one value for each argument but the last), and each returned value must be the same as or a chaperone of the corresponding argument. The guard-proc is added as a constructor guard when a subtype is created of the chaperoned structure type.

Pairs of prop and prop-val (the number of arguments to chaperone-struct-type must be even) add impersonator properties or override impersonator-property values of struct-type.

> ```
(chaperone-evt evt proc prop prop-val ... ...)
   →   (and/c evt? chaperone?)
  evt : evt?
  proc : (evt? .  →  . (values evt? (any/c .  →  . any/c)))
  prop : impersonator-property?
  prop-val : any/c```

Returns a chaperoned value like evt, but with proc as an event generator when the result is synchronized with functions like [sync](sync.html#%28def._%28%28quote._~23~25kernel%29._sync%29%29).

The proc generator is called on synchronization, much like the procedure passed to [guard-evt](sync.html#%28def._%28%28lib._racket%2Fprivate%2Fmisc..rkt%29._guard-evt%29%29), except that proc is given evt. The proc must return two values: a [synchronizable event](sync.html#%28tech._synchronizable._event%29) that is a chaperone of evt, and a procedure that is used to check the event’s result if it is chosen in a selection. The latter procedure accepts the result of evt, and it must return a chaperone of that value.

Pairs of prop and prop-val (the number of arguments to [chaperone-evt](#%28def._%28%28quote._~23~25kernel%29._chaperone-evt%29%29) must be even) add impersonator properties or override impersonator-property values of evt.

The result is [chaperone-of?](#%28def._%28%28quote._~23~25kernel%29._chaperone-of~3f%29%29) the argument evt. However, if evt is a [thread](eval-model.html#%28tech._thread%29), [semaphore](semaphore.html#%28tech._semaphore%29), [input port](ports.html#%28tech._input._port%29), [output port](ports.html#%28tech._output._port%29), or [will executor](willexecutor.html#%28tech._will._executor%29), the result is not recognized as such. For example, [thread?](threads.html#%28def._%28%28quote._~23~25kernel%29._thread~3f%29%29) applied to the result of [chaperone-evt](#%28def._%28%28quote._~23~25kernel%29._chaperone-evt%29%29) will always produce #f.

> ```
(chaperone-channel channel
    get-proc
    put-proc
    prop
    prop-val ...
    ...)    →    (and/c channel? chaperone?)

  channel : channel?
  get-proc : (channel? .  →  . (values channel? (any/c .  →  . any/c)))
  put-proc : (channel? any/c .  →  . any/c)
  prop : impersonator-property?
  prop-val : any/c
```


# 13.11 Cryptographic Hashing
Like impersonate-channel, but with restrictions on the get-proc and put-proc procedures.
The get-proc must return two values: a channel that is a chaperone of channel, and a procedure that is used to check the channel’s contents. The latter procedure must return the original value or a chaperone of that value.
The put-proc must produce a replacement value that is either the original value communicated on the channel or a chaperone of that value.
Pairs of prop and prop-val (the number of arguments to chaperone-channel must be odd) add impersonator properties or override impersonator-property values of channel.
> ```
(chaperone-prompt-tag prompt-tag
    handle-proc
    abort-proc
   [ cc-guard-proc
    callcc-chaperone-proc]
    prop
    prop-val ...
    ...)
   →   (and/c continuation-prompt-tag? chaperone?)
  prompt-tag : continuation-prompt-tag?
  handle-proc : procedure?
  abort-proc : procedure?
  cc-guard-proc : procedure? = values
   callcc-chaperone-proc   :   (procedure? .  →  . procedure?)
      =   (lambda (p) p)
  prop : impersonator-property?
  prop-val : any/c```


# 13.11 Cryptographic Hashing
Like [impersonate-prompt-tag](#%28def._%28%28quote._~23~25kernel%29._impersonate-prompt-tag%29%29), but produces a chaperoned value. The handle-proc procedure must produce the same values or chaperones of the original values, abort-proc must produce the same values or chaperones of the values that it is given, and cc-guard-proc must produce the same values or chaperones of the original result values, and callcc-chaperone-proc must produce a procedure that is a chaperone or the same as the given procedure.
Examples:
> ```racket
> > ( define bad-chaperone ( chaperone-prompt-tag ( make-continuation-prompt-tag ) ( lambda ( n ) ( * n 2 ) ) ( lambda ( n ) ( + n 1 ) ) ) )
> > ( call-with-continuation-prompt ( lambda ( ) ( abort-current-continuation bad-chaperone 5 ) ) bad-chaperone ( lambda ( n ) n ) )
> abort-current-continuation: non-chaperone result; received a
> prompt-abort argument that is not a chaperone of the
> original prompt-abort argument
> original: 5
> received: 6
> > ( define good-chaperone ( chaperone-prompt-tag ( make-continuation-prompt-tag ) ( lambda ( n ) ( if ( even? n ) n ( error "not even" ) ) ) ( lambda ( n ) ( if ( even? n ) n ( error "not even" ) ) ) ) )
> > ( call-with-continuation-prompt ( lambda ( ) ( abort-current-continuation good-chaperone 2 ) ) good-chaperone ( lambda ( n ) n ) )
> 2
> ```
> ```
(chaperone-continuation-mark-key key
    get-proc
    set-proc
    prop
    prop-val ...
    ...)


# 13.11 Cryptographic Hashing
  →  (and/c continuation-mark-key? chaperone?)
  key : continuation-mark-key?
  get-proc : procedure?
  set-proc : procedure?
  prop : impersonator-property?
  prop-val : any/c
```
(parameter)	→
(-> with-continuation-mark bad-chaperone "timballo" (continuation-mark-set-first (current-continuation-marks) bad-chaperone))```

Creates a new [impersonator property](#%28tech._impersonator._property%29) and returns three values:

-   an impersonator property descriptor, for use with [impersonate-procedure](#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._impersonate-procedure%29%29), [chaperone-procedure](#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._chaperone-procedure%29%29), and other impersonator constructors;

-   an impersonator property predicate procedure, which takes an arbitrary value and returns #t if the value is an impersonator with a value for the property, #f otherwise;

-   an impersonator property accessor procedure, which returns the value associated with an impersonator for the property; if a value given to the accessor is not an impersonator or does not have a value for the property (i.e. if the corresponding impersonator property predicate returns #f), then a second optional argument to the selector determines its response: the [exn:fail:contract](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3acontract%29%29) exception is raised if a second argument is not provided, the second argument is tail-called with zero arguments if it is a procedure, and the second argument is returned otherwise.

> ```
(impersonator-property? v)  →  boolean?
  v : any/c
```


# 13.11 Cryptographic Hashing
Returns #t if v is a impersonator property descriptor value, #f otherwise.
> ```
(impersonator-property-accessor-procedure? v)   →   boolean?
  v : any/c```
Returns #t if v is an accessor procedure produced by [make-impersonator-property](#%28def._%28%28quote._~23~25kernel%29._make-impersonator-property%29%29), #f otherwise.
>
<colgroup><col style="width: 100%" /></colgroup>

value

[impersonator-prop:application-mark](#%28def._%28%28quote._~23~25kernel%29._impersonator-prop~3aapplication-mark%29%29) : [impersonator-property?](#%28def._%28%28quote._~23~25kernel%29._impersonator-property~3f%29%29)

An [impersonator property](#%28tech._impersonator._property%29) that is recognized by [impersonate-procedure](#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._impersonate-procedure%29%29) and [chaperone-procedure](#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._chaperone-procedure%29%29).
------------------------------------------------------------------------


# 14.6 Security Guards


### 14.6 Security Guards
> ```
(security-guard? v)  →  boolean?
  v : any/c
```
(parameter)	→
(-> symbol?
    (or/c path? #f)
    (listof symbol?)
    . → . any)```

Creates a new security guard as child of parent.

The file-guard procedure must accept three arguments:

-   a symbol for the primitive procedure that triggered the access check, which is useful for raising an exception to deny access.

-   a path (see [Paths](pathutils.html)) or #f for pathless queries, such as ([current-directory](Filesystem.html#%28def._%28%28quote._~23~25kernel%29._current-directory%29%29)), ([filesystem-root-list](Filesystem.html#%28def._%28%28quote._~23~25kernel%29._filesystem-root-list%29%29)), and ([find-system-path](Filesystem.html#%28def._%28%28quote._~23~25kernel%29._find-system-path%29%29) symbol). A path provided to file-guard is not expanded or otherwise normalized before checking access; it may be a relative path, for example.

-   a list containing one or more of the following symbols:

    -   'read — read a file or directory

    -   'write — modify or create a file or directory

    -   'execute — execute a file

    -   'delete — delete a file or directory

    -   'exists — determine whether a file or directory exists, or that a path string is well-formed

    The 'exists symbol is never combined with other symbols in the last argument to file-guard, but any other combination is possible. When the second argument to file-guard is #f, the last argument always contains only 'exists.

The network-guard procedure must accept four arguments:

-   a symbol for the primitive operation that triggered the access check, which is useful for raising an exception to deny access.

-   an immutable string representing the target hostname for a client connection or the accepting hostname for a listening server; #f for a listening server or UDP socket that accepts connections at all of the host’s address; or #f an unbound UDP socket.

-   an exact integer between 1 and 65535 (inclusive) representing the port number, or #f for an unbound UDP socket. In the case of a client connection, the port number is the target port on the server. For a listening server, the port number is the local port number.

-   a symbol, either 'client or 'server, indicating whether the check is for the creation of a client connection or a listening server. The opening of an unbound UDP socket is identified as a 'client connection; explicitly binding the socket is identified as a 'server action.

The link-guard argument can be #f or a procedure of three arguments:

-   a symbol for the primitive procedure that triggered the access check, which is useful for raising an exception to deny access.

-   a complete path (see [Paths](pathutils.html)) representing the file to create as link.

-   a path representing the content of the link, which may be relative the second-argument path; this path is not expanded or otherwise normalized before checking access.

If link-guard is #f, then a default procedure is used that always raises [exn:fail](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail%29%29).

The return value of file-guard, network-guard, or link-guard is ignored. To deny access, the procedure must raise an exception or otherwise escape from the context of the primitive call. If the procedure returns, the parent’s corresponding procedure is called on the same inputs, and so on up the chain of security guards.

The file-guard, network-guard, and link-guard procedures are invoked in the thread that called the access-checked primitive. Breaks may or may not be enabled (see [Breaks](breakhandler.html)). Full continuation jumps are blocked going into or out of the file-guard or network-guard call (see [Prompts, Delimited Continuations, and Barriers](eval-model.html#%28part._prompt-model%29)).

> ```
(current-security-guard)	→
(-> current-security-guard guard)
(current-security-guard guard) → void?
    guard	:
(-> current-security-guard guard)
```


# 14.6 Security Guards
A parameter that determines the current security guard that controls access to the filesystem and network.
------------------------------------------------------------------------


# 14.7 Custodians


### 14.7 Custodians
See Custodians for basic information on the Racket custodian model.
> ```
(custodian? v)   →   boolean?
  v : any/c```
Returns #t if v is a [custodian](eval-model.html#%28tech._custodian%29) value, #f otherwise.
> ```
(current-custodian)	→
(-> and/c custodian? (not/c custodian-shut-down?))
```
(parameter)	→```

> > > In [racket/gui/base](https://plt.cs.northwestern.edu/new-snapshots/new-snapshots/doc/local-redirect/index.html?doc=gui&rel=index.html&version=8.18.0.13), [eventspaces](https://plt.cs.northwestern.edu/new-snapshots/new-snapshots/doc/local-redirect/index.html?doc=gui&rel=windowing-overview.html%23%2528tech._eventspace%2529&version=8.18.0.13) managed by cust are also shut down.

Closes all [file-stream ports](file-ports.html#%28tech._file._stream._port%29), [TCP ports](tcp.html#%28tech._tcp._port%29), [TCP listeners](tcp.html#%28tech._tcp._listener%29), and [UDP sockets](udp.html#%28tech._udp._socket%29) that are managed by cust (and its subordinates), and empties all [custodian box](eval-model.html#%28tech._custodian._box%29)es associated with cust (and its subordinates). It also removes cust (and its subordinates) as managers of all threads; when a thread has no managers, it is killed (or suspended; see [thread/suspend-to-kill](threads.html#%28def._%28%28quote._~23~25kernel%29._thread%2Fsuspend-to-kill%29%29)) If the current thread is to be killed, all other shut-down actions take place before killing the thread.

If cust is already shut down, then [custodian-shutdown-all](#%28def._%28%28quote._~23~25kernel%29._custodian-shutdown-all%29%29) has no effect. When a custodian is shut down and it has subordinate custodians, the subordinates are not only shut down, they no longer count as subordinates.

> ```
(custodian-shut-down? cust)  →  boolean?
  cust : custodian?
```


# 14.7 Custodians
(current-custodian)	→
(-> current-custodian cust)
(current-custodian cust) → void?
    cust	:
(-> current-custodian cust)```
> > > Custodians also manage [eventspaces](https://plt.cs.northwestern.edu/new-snapshots/new-snapshots/doc/local-redirect/index.html?doc=gui&rel=windowing-overview.html%23%2528tech._eventspace%2529&version=8.18.0.13) from [racket/gui/base](https://plt.cs.northwestern.edu/new-snapshots/new-snapshots/doc/local-redirect/index.html?doc=gui&rel=index.html&version=8.18.0.13).
A [parameter](eval-model.html#%28tech._parameter%29) that determines a custodian that assumes responsibility for newly created threads, [file-stream ports](file-ports.html#%28tech._file._stream._port%29), TCP ports, [TCP listeners](tcp.html#%28tech._tcp._listener%29), [UDP sockets](udp.html#%28tech._udp._socket%29), and [byte converters](bytestrings.html#%28tech._byte._converter%29).
> ```
(custodian-managed-list cust super)  →  list?
  cust : custodian?
  super : custodian?


# 14.7 Custodians
```
Returns a list of immediately managed objects (not including custodian boxes) and subordinate custodians for cust, where cust is itself subordinate to super (directly or indirectly). If cust is not strictly subordinate to super, the exn:fail:contract exception is raised.

If cust has been shut down, the result is '(). If cust was a subordinate of a custodian that was shut down, then it cannot be a subordinate of super.

> ```
(custodian-memory-accounting-available?)   →   boolean?```

> > > Memory accounting is normally available, but not in the [CGC](implementations.html#%28tech._cgc%29) implementation.

Returns #t if Racket is compiled with support for per-custodian memory accounting, #f otherwise.

> ```
(parameter)	→
```
(parameter)	→```
Registers a limited-memory check if Racket is compiled with support for per-custodian memory accounting, otherwise the [exn:fail:unsupported](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3aunsupported%29%29) exception is raised.
If a check is registered, and if Racket later reaches a state after garbage collection (see [Garbage Collection](eval-model.html#%28part._gc-model%29)) where limit-cust owns more than limit-amt bytes, then stop-cust is shut down.


# 14.7 Custodians
> > > A custodian’s limit is checked only after a garbage collection, except that it may also be checked during certain large allocations that are individually larger than the custodian’s limit. A single garbage collection may shut down multiple custodians, even if shutting down only one of the custodians would have reduced memory use for other custodians.
For reliable shutdown, limit-amt for [custodian-limit-memory](#%28def._%28%28quote._~23~25kernel%29._custodian-limit-memory%29%29) must be much lower than the total amount of memory available (minus the size of memory that is potentially used and not charged to limit-cust). Moreover, if individual allocations that are initially charged to limit-cust can be arbitrarily large, then stop-cust must be the same as limit-cust, so that excessively large immediate allocations can be rejected with an [exn:fail:out-of-memory](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3aout-of-memory%29%29) exception.
> > > New memory allocation will be accounted to the running [thread](threads.html)’s managing custodian. In other words, a custodian’s limit applies only to the allocation made by the threads that it manages. See also [call-in-nested-thread](threads.html#%28def._%28%28quote._~23~25kernel%29._call-in-nested-thread%29%29) for a simpler setup.
Examples:


# 14.7 Custodians
> ```racket
> > ( require racket/async-channel )
> > ( define ch ( make-async-channel ) )
> > ( parameterize ( [ current-custodian ( make-custodian ) ] ) ( thread-wait ( thread ( λ ( ) ( with-handlers ( [ exn:fail:out-of-memory? ( λ ( e ) ( async-channel-put ch e ) ) ] ) ( custodian-limit-memory ( current-custodian ) ( * 1024 1024 ) ) ( make-bytes ( * 4 1024 1024 ) ) ( async-channel-put ch "Not OK" ) ) ) ) ) ( async-channel-get ch ) )
> (exn:fail:out-of-memory "out of memory" #<continuation-mark-set>)
> > ( define cust ( make-custodian ) )
> > ( with-handlers ( [ exn:fail:out-of-memory? ( λ ( e ) ( error "Caught OOM exn" ) ) ] ) ( call-in-nested-thread ( λ ( ) ( custodian-limit-memory cust ( * 1024 1024 ) ) ( make-bytes ( * 4 1024 1024 ) ) "Not OK" ) cust ) )
> Caught OOM exn
> ```
Non-examples:
> ```racket
> > ( parameterize ( [ current-custodian ( make-custodian ) ] ) ( custodian-limit-memory ( current-custodian ) ( * 1024 1024 ) ) ; Allocation of make-bytes is charged to the current thread’s ; managing custodian, not the new custodian. ( make-bytes ( * 4 1024 1024 ) ) "Not OK" )
> "Not OK"
> ```
> ```
(make-custodian-box cust v)  →  custodian-box?
  cust : custodian?
  v : any/c


# 14.7 Custodians
```
Returns a custodian box that contains v as long as cust has not been shut down. If cust is already shut down, the custodian box’s value is immediately removed.

A custodian box is a synchronizable event (see Events). The custodian box becomes ready when its custodian is shut down; the synchronization result of a custodian box is the custodian box itself.

> ```
(custodian-box? v)   →   boolean?
  v : any/c```

Returns #t if v is a [custodian box](eval-model.html#%28tech._custodian._box%29) produced by [make-custodian-box](#%28def._%28%28quote._~23~25kernel%29._make-custodian-box%29%29), #f otherwise.

> ```
(custodian-box-value cb)  →  any
  cb : custodian-box?
```
(current-thread-group)	→
(-> current-thread-group)```
Creates a new thread group that belongs to group.
> ```
(thread-group? v)  →  boolean?
  v : any/c


# 14.7 Custodians
```
(current-thread-group)	→
(-> current-thread-group group)
(current-thread-group group) → void?
    group	:
(-> current-thread-group group)```

A [parameter](eval-model.html#%28tech._parameter%29) that determines the thread group for newly created threads.

------------------------------------------------------------------------

# 14.9 Structure Inspectors

### 14.9 Structure Inspectors

An inspector provides access to structure fields and structure type information without the normal field accessors and mutators. (Inspectors are also used to control access to module bindings; see [Code Inspectors](modprotect.html).) Inspectors are primarily intended for use by debuggers.

When a structure type is created, an inspector can be supplied. The given inspector is not the one that will control the new structure type; instead, the given inspector’s parent will control the type. By using the parent of the given inspector, the structure type remains opaque to “peer” code that cannot access the parent inspector.

The [current-inspector](#%28def._%28%28quote._~23~25kernel%29._current-inspector%29%29) [parameter](eval-model.html#%28tech._parameter%29) determines a default inspector argument for new structure types. An alternate inspector can be provided though the #:inspector option of the [struct](define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29) form (see [Defining Structure Types: struct](define-struct.html)), or through an optional inspector argument to [make-struct-type](creatingmorestructs.html#%28def._%28%28quote._~23~25kernel%29._make-struct-type%29%29).

> ```
(inspector? v)  →  boolean?
  v : any/c
```


# 14.7 Custodians
(current-inspector)	→
(-> current-inspector)```
Returns a new inspector that is a subinspector of inspector. Any structure type controlled by the new inspector is also controlled by its ancestor inspectors, but no other inspectors.
> ```
(current-inspector)	→
(-> current-inspector)
```

Returns a new inspector that is a subinspector of the same inspector as inspector. That is, inspector and the result inspector control mutually disjoint sets of structure types.

> ```
(inspector-superior?   inspector
    maybe-subinspector)    →    boolean?

  inspector : inspector?
  maybe-subinspector : inspector?
```
Returns #t if inspector is an ancestor of maybe-subinspector (and not equal to maybe-subinspector), #f otherwise.
Added in version 6.5.0.6 of package base.
> ```
(current-inspector)	→
(-> current-inspector insp)
(current-inspector insp) → void?
    insp	:
(-> current-inspector insp)
```
(parameter)	→
(-> or/c struct-type? #f)```

Returns two values:

-   struct-type: a structure type descriptor or #f; the result is a structure type descriptor of the most specific type for which v is an instance, and for which the current inspector has control, or the result is #f if the current inspector does not control any structure type for which the [struct](define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29) is an instance.

-   skipped?: #f if the first result corresponds to the most specific structure type of v, #t otherwise.

> ```
(parameter)	→
(-> listof exact-nonnegative-integer?)
```


# 14.7 Custodians
Returns eight values that provide information about the structure type descriptor struct-type, assuming that the type is controlled by the current inspector:
-  name: the structure type’s name as a symbol;
-  init-field-cnt: the number of fields defined by the structure type provided to the constructor procedure (not counting fields created by its ancestor types);
-  auto-field-cnt: the number of fields defined by the structure type without a counterpart in the constructor procedure (not counting fields created by its ancestor types);
-  accessor-proc: an accessor procedure for the structure type, like the one returned by make-struct-type;
-  mutator-proc: a mutator procedure for the structure type, like the one returned by make-struct-type;
-  immutable-k-list: an immutable list of exact non-negative integers that correspond to immutable fields for the structure type;
-  super-type: a structure type descriptor for the most specific ancestor of the type that is controlled by the current inspector, or #f if no ancestor is controlled by the current inspector;
-  skipped?: #f if the seventh result is the most specific ancestor type or if the type has no supertype, #t otherwise.
If the type for struct-type is not controlled by the current inspector, the exn:fail:contract exception is raised.
> ```
(struct-type-sealed? struct-type)   →   boolean?
  struct-type : struct-type?```
Reports whether struct-type has the [prop:sealed](creatingmorestructs.html#%28def._%28%28quote._~23~25kernel%29._prop~3asealed%29%29) structure type property.


# 14.7 Custodians
Added in version 8.0.0.7 of package base.
> ```
(struct-type-authentic? struct-type)  →  boolean?
  struct-type : struct-type?
```
(parameter)	→
(-> or/c symbol? #f)```

Returns a [constructor](define-struct.html#%28tech._constructor%29) procedure to create instances of the type for struct-type. If constructor-name is not #f, it is used as the name of the generated [constructor](define-struct.html#%28tech._constructor%29) procedure. If the type for struct-type is not controlled by the current inspector, the [exn:fail:contract](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3acontract%29%29) exception is raised.

> ```
(struct-type-make-predicate struct-type)  →  any
  struct-type : any/c
```
Returns a predicate procedure to recognize instances of the type for struct-type. If the type for struct-type is not controlled by the current inspector, the exn:fail:contract exception is raised.
> ```
(object-name v)   →   any
  v : any/c```


# 14.7 Custodians
Returns a value for the name of v if v has a name, #f otherwise. The argument v can be any value, but only (some) procedures, [structures](structures.html#%28tech._structure%29), [structure types](structures.html#%28tech._structure._type%29), [structure type properties](structprops.html#%28tech._structure._type._property%29), [regexp values](regexp.html#%28tech._regexp._value%29), [ports](ports.html#%28tech._port%29), [loggers](logging.html#%28tech._logger%29), and [prompt tags](eval-model.html#%28tech._prompt._tag%29) have names. See also [Inferred Value Names](syntax-model.html#%28part._infernames%29).


# 14.7 Custodians
If a [structure](structures.html#%28tech._structure%29)’s type implements the [prop:object-name](#%28def._%28%28quote._~23~25kernel%29._prop~3aobject-name%29%29) property, and the value of the [prop:object-name](#%28def._%28%28quote._~23~25kernel%29._prop~3aobject-name%29%29) property is an integer, then the corresponding field of the structure is the name of the structure. Otherwise, the property value must be a procedure, which is called with the structure as argument, and the result is the name of the structure. If a [structure](structures.html#%28tech._structure%29) is a procedure as implemented by one of its fields (i.e., the [prop:procedure](procedures.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._prop~3aprocedure%29%29) property value for the structure’s type is an integer), then its name is the implementing procedure’s name. Otherwise, its name matches the name of the [structure type](structures.html#%28tech._structure._type%29) that it instantiates.
The name (if any) of a procedure is a symbol, unless the procedure is also a structure whose type has the [prop:object-name](#%28def._%28%28quote._~23~25kernel%29._prop~3aobject-name%29%29) property, in which case [prop:object-name](#%28def._%28%28quote._~23~25kernel%29._prop~3aobject-name%29%29) takes precedence. The [procedure-rename](procedures.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._procedure-rename%29%29) function creates a procedure with a specific name.


# 14.7 Custodians
The name of a [regexp value](regexp.html#%28tech._regexp._value%29) is a string or byte string. Passing the string or byte string to [regexp](regexp.html#%28def._%28%28quote._~23~25kernel%29._regexp%29%29), [byte-regexp](regexp.html#%28def._%28%28quote._~23~25kernel%29._byte-regexp%29%29), [pregexp](regexp.html#%28def._%28%28quote._~23~25kernel%29._pregexp%29%29), or [byte-pregexp](regexp.html#%28def._%28%28quote._~23~25kernel%29._byte-pregexp%29%29) (depending on the kind of regexp whose name was extracted) produces a value that matches the same inputs.
The name of a port can be any value, but many tools use a path or string name as the port’s for (to report source locations, for example).
The name of a [logger](logging.html#%28tech._logger%29) is either a symbol or #f.
The name of a [prompt tag](eval-model.html#%28tech._prompt._tag%29) is either the optional symbol given to [make-continuation-prompt-tag](cont.html#%28def._%28%28quote._~23~25kernel%29._make-continuation-prompt-tag%29%29) or #f.
Changed in version 7.9.0.13 of package base: Recognize the name of continuation prompt tags.
>
<colgroup><col style="width: 100%" /></colgroup>

value

[prop:object-name](#%28def._%28%28quote._~23~25kernel%29._prop~3aobject-name%29%29) : [struct-type-property?](structprops.html#%28def._%28%28quote._~23~25kernel%29._struct-type-property~3f%29%29)