### 2.3 Notation for Function Documentation
Procedures and other values are described using a notation based on [contract](contracts.html#%28tech._contract%29)s. In essence, these contracts describe the interfaces of the documented library using Racket predicates and expressions.
For example, the following is the header of the definition of a typical procedure:
> > ```
(char  →  integer char)  →  exact-integer?
  char : char?
```
The function being defined, char  →  integer, is typeset as if it were being applied. The metavariables that come after the function name stand in for arguments. The white text in the corner identifies the kind of value that is being documented.

Each metavariable is described with a contract. In the preceding example, the metavariable char has the contract char?. This contract specifies that any argument char that answers true to the char? predicate is valid. The documented function may or may not actually check this property, but the contract signals the intent of the implementer.

The contract on the right of the arrow, exact-integer? in this case, specifies the expected result that is produced by the function.

Contract specifications can be more expressive than just names of predicates. Consider the following header for argmax:

> > ```
(argmax proc lst)   →   any
  proc : (  →   any/c real?)
  lst : (and/c pair? list?)```

The contract ([->](function-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._-~3e%29%29) [any/c](data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29) [real?](number-types.html#%28def._%28%28quote._~23~25kernel%29._real~3f%29%29)) denotes a function contract specifying that proc’s argument can be any single value and the result should be a real number. The contract ([and/c](data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._and%2Fc%29%29) [pair?](pairs.html#%28def._%28%28quote._~23~25kernel%29._pair~3f%29%29) [list?](pairs.html#%28def._%28%28quote._~23~25kernel%29._list~3f%29%29)) for lst specifies that lst should pass both [pair?](pairs.html#%28def._%28%28quote._~23~25kernel%29._pair~3f%29%29) and [list?](pairs.html#%28def._%28%28quote._~23~25kernel%29._list~3f%29%29) (i.e., that it is a non-empty list).

Both [->](function-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._-~3e%29%29) and [and/c](data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._and%2Fc%29%29) are examples of [contract combinator](contracts.html#%28tech._contract._combinator%29)s. Contract combinators such as [or/c](data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._or%2Fc%29%29), [cons/c](data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._cons%2Fc%29%29), [listof](data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._listof%29%29), and others are used throughout the documentation. Clicking on the hyperlinked combinator name will provide more information on its meaning.

A Racket function may be documented as having one or more optional arguments. The [read](Reading.html#%28def._%28%28quote._~23~25kernel%29._read%29%29) function is an example of such a function:

> > ```
(current-input-port)	→
(-> current-input-port)
```


### 2.3 Notation for Function Documentation
(current-input-port)	→
(-> any/c any/c . → . any/c)```
The brackets around the extract-key and cache-keys? arguments indicate that they are optional as before. The contract section of the header shows the default values that are provided for these keyword arguments.


### 2.4 Notation for Structure Type Documentation
A [structure type](structures.html#%28tech._structure._type%29) is also documented using contract notation:
> >
<colgroup><col style="width: 100%" /></colgroup>

struct

([struct](define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29) color (red green blue alpha))

  red : ([and/c](data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._and%2Fc%29%29) [natural-number/c](data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._natural-number%2Fc%29%29) ([<=/c](data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._~3c~3d%2Fc%29%29) 255))

  green : ([and/c](data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._and%2Fc%29%29) [natural-number/c](data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._natural-number%2Fc%29%29) ([<=/c](data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._~3c~3d%2Fc%29%29) 255))

  blue : ([and/c](data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._and%2Fc%29%29) [natural-number/c](data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._natural-number%2Fc%29%29) ([<=/c](data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._~3c~3d%2Fc%29%29) 255))

  alpha : ([and/c](data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._and%2Fc%29%29) [natural-number/c](data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._natural-number%2Fc%29%29) ([<=/c](data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._~3c~3d%2Fc%29%29) 255))


### 2.4 Notation for Structure Type Documentation
The structure type is typeset as it were declared in the source code of a program using the [struct](define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29) form. Each field of the structure is documented with a corresponding contract that specifies the values that are accepted for that field.
In the example above, the structure type color has four fields: red, green, blue, and alpha. The constructor for the structure type accepts field values that satisfy ([and/c](data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._and%2Fc%29%29) [natural-number/c](data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._natural-number%2Fc%29%29) ([<=/c](data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._~3c~3d%2Fc%29%29) 255)), i.e., non-negative exact integers up to 255.
Additional keywords may appear after the field names in the documentation for a structure type:
> >
<colgroup><col style="width: 100%" /></colgroup>

struct


### 2.4 Notation for Structure Type Documentation

([struct](define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29)	 	data-source (connector args extensions)

    #:mutable)

  connector : ([or/c](data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._or%2Fc%29%29) 'postgresql 'mysql 'sqlite3 'odbc)

  args : [list?](pairs.html#%28def._%28%28quote._~23~25kernel%29._list~3f%29%29)

  extensions : ([listof](data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._listof%29%29) ([list/c](data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._list%2Fc%29%29) [symbol?](symbols.html#%28def._%28%28quote._~23~25kernel%29._symbol~3f%29%29) [any/c](data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29)))

Here, the #:mutable keyword indicates that the fields of instances of the data-source structure type can be mutated with their respective setter functions.


### 2.5 Notation for Parameter Documentation
A [parameter](eval-model.html#%28tech._parameter%29) is documented the same way as a function:
> > ```
(current-command-line-arguments)	→
(-> vectorof string?)
(current-command-line-arguments argv) → void?
    argv	:
(-> vectorof string?)
```
(current-module-declare-name)	→
(-> module duck racket/base (provide num-eggs quack) (define num-eggs 2) (define (quack n) (unless (zero? n) (printf "quack\n") (quack (sub1 n)))))```

>
>

>
>

>
> Specifies a library available via the PLaneT server.
>
>

>
> The first form is a shorthand for the last one, where the id’s character sequence must match the following ‹spec› grammar:
>
> |     |           |        |                                                 |
> |-----|-----------|--------|-------------------------------------------------|
> |     | ‹spec›    |  ::=   | ‹owner› / ‹pkg› ‹lib›                           |
> |     | ‹owner›   |  ::=   | ‹elem›                                          |
> |     | ‹pkg›     |  ::=   | ‹elem›  \|  ‹elem› : ‹version›                  |
> |     | ‹version› |  ::=   | ‹int›  \|  ‹int› : ‹minor›                      |
> |     | ‹minor›   |  ::=   | ‹int›  \|  \<= ‹int›  \|>= ‹int›  \|  = ‹int› |
> |     |           |   \|   | ‹int› - ‹int›                                   |
> |     | ‹lib›     |  ::=   | ‹empty›  \|  / ‹path›                           |
> |     | ‹path›    |  ::=   | ‹elem›  \|  ‹elem› / ‹path›                     |
>
> and where an ‹elem› is a non-empty sequence of characters that are ASCII letters, ASCII digits, -, +, \_, or % followed by lowercase hexadecimal digits (that do not encode one of the other allowed characters), and an ‹int› is a non-empty sequence of ASCII digits. As this shorthand is expended, a ".plt" extension is added to ‹pkg›, and a ".rkt" extension is added to ‹path›; if no ‹path› is included, "main.rkt" is used in the expansion.
>
> A ([planet](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._planet%29%29) string) form is like a ([planet](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._planet%29%29) id) form with the identifier converted to a string, except that the string can optionally end with a file extension (i.e., a .) for a ‹path›. A ".ss" file extension is converted to ".rkt".
>
> In the more general last form of a [planet](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._planet%29%29) module path, the rel-strings are similar to the [lib](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._lib%29%29) form, except that the (user-string pkg-string vers) names a PLaneT-based package instead of a [collection](collects.html#%28tech._collection%29). A version specification can include an optional major and minor version, where the minor version can be a specific number or a constraint: (nat nat) specifies an inclusive range, (= nat) specifies an exact match, (+ nat) specifies a minimum version and is equivalent to just nat, and (- nat) specifies a maximum version. The =, +, and - identifiers in a minor-version constraint are recognized symbolically.
>
>

>
> Examples:
>
>

>
>

>
> > ```racket
> > ; "main.rkt" in package "farm" by "mcdonald" :
> > > ( require ( planet mcdonald/farm ) )
> > ; "main.rkt" in version >= 2.0 of "farm" by "mcdonald" :
> > > ( require ( planet mcdonald/farm:2 ) )
> > ; "main.rkt" in version >= 2.5 of "farm" by "mcdonald" :
> > > ( require ( planet mcdonald/farm:2:5 ) )
> > ; "duck.rkt" in version >= 2.5 of "farm" by "mcdonald" :
> > > ( require ( planet mcdonald/farm:2:5/duck ) )
> > ```
>
>

>

>
> > <table data-cellpadding="0" data-cellspacing="0"><colgroup><col style="width: 100%" /></colgroup><tbody><tr><td><blockquote>

<p>syntax</p>

<p>([submod](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._submod%29%29) root-module-path submod-path-element ...)</p></blockquote></td></tr><tr><td>([submod](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._submod%29%29) "." submod-path-element ...)</td></tr><tr><td>([submod](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._submod%29%29) ".." submod-path-element ...)</td></tr></tbody></table>
>
>

>
>

>
> Identifies a [submodule](eval-model.html#%28tech._submodule%29) within the module specified by root-module-path or relative to the current module in the case of ([submod](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._submod%29%29) "." ....), where ([submod](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._submod%29%29) ".." submod-path-element [...](stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29)) is equivalent to ([submod](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._submod%29%29) "." ".." submod-path-element [...](stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29)). Submodules have symbolic names, and a sequence of identifiers as submod-path-elements determine a path of successively nested submodules with the given names. A ".." as a submod-path-element names the enclosing module of a submodule, and it’s intended for use in ([submod](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._submod%29%29) "." ....) and ([submod](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._submod%29%29) ".." ....) forms.
>
>

As [require](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) prepares to handle a sequence of require-specs, it logs a “prefetch” message to the [current logger](logging.html#%28tech._current._logger%29) at the 'info level, using the name 'module-prefetch, and including message data that is a list of two elements: a list of [module paths](Module_Names_and_Loading.html#%28tech._module._path%29) that appear to be imported, and a directory path to use for relative module paths. The logged list of module paths may be incomplete, but a compilation manager can use approximate prefetch information to start on compilations in parallel.

Changed in version 6.0.1.10 of package base: Added prefetch logging.

> <table data-cellpadding="0" data-cellspacing="0"><colgroup><col style="width: 100%" /></colgroup><tbody><tr><td><blockquote>

<p>syntax</p>

<p>([local-require](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._local-require%29%29) require-spec ...)</p></blockquote></td></tr></tbody></table>

Like [require](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29), but for use in a [internal-definition context](syntax-model.html#%28tech._internal._definition._context%29) to import just into the local context. Only bindings from [phase level](syntax-model.html#%28tech._phase._level%29) 0 are imported.

Examples:

> ```racket
> > ( let ( ) ( local-require racket/control ) fcontrol )
> #<procedure:fcontrol>
> > fcontrol
> fcontrol: undefined;
> cannot reference an identifier before its definition
> in module: top-level
> ```

> > > <img src="finger.png" width="24" height="24" alt="+" />[Exports: provide](https://plt.cs.northwestern.edu/new-snapshots/new-snapshots/doc/local-redirect/index.html?doc=guide&rel=module-provide.html&version=8.18.0.13) in [The Racket Guide](https://plt.cs.northwestern.edu/new-snapshots/new-snapshots/doc/local-redirect/index.html?doc=guide&rel=index.html&version=8.18.0.13) introduces [provide](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._provide%29%29).

> <table data-cellpadding="0" data-cellspacing="0"><colgroup><col style="width: 100%" /></colgroup><tbody><tr><td><blockquote>

<p>syntax</p>

<p>([provide](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._provide%29%29) provide-spec ...)</p></blockquote></td></tr><tr><td> </td></tr><tr><td><table data-cellpadding="0" data-cellspacing="0"><tbody><tr><td style="text-align: right;" data-valign="baseline">provide-spec</td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: center;" data-valign="baseline">=</td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline">id</td></tr><tr><td style="text-align: right;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: center;" data-valign="baseline">|</td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline">([all-defined-out](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._all-defined-out%29%29))</td></tr><tr><td style="text-align: right;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: center;" data-valign="baseline">|</td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline">([all-from-out](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._all-from-out%29%29) module-path ...)</td></tr><tr><td style="text-align: right;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: center;" data-valign="baseline">|</td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline">([rename-out](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._rename-out%29%29) [orig-id export-id] ...)</td></tr><tr><td style="text-align: right;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: center;" data-valign="baseline">|</td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline">([except-out](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._except-out%29%29) provide-spec provide-spec ...)</td></tr><tr><td style="text-align: right;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: center;" data-valign="baseline">|</td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline">([prefix-out](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._prefix-out%29%29) prefix-id provide-spec)</td></tr><tr><td style="text-align: right;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: center;" data-valign="baseline">|</td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline">([struct-out](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct-out%29%29) id)</td></tr><tr><td style="text-align: right;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: center;" data-valign="baseline">|</td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline">([combine-out](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._combine-out%29%29) provide-spec ...)</td></tr><tr><td style="text-align: right;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: center;" data-valign="baseline">|</td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline">([protect-out](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._protect-out%29%29) provide-spec ...)</td></tr><tr><td style="text-align: right;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: center;" data-valign="baseline">|</td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline">([for-meta](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._for-meta%29%29) phase-level provide-spec ...)</td></tr><tr><td style="text-align: right;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: center;" data-valign="baseline">|</td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline">([for-syntax](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._for-syntax%29%29) provide-spec ...)</td></tr><tr><td style="text-align: right;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: center;" data-valign="baseline">|</td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline">([for-template](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._for-template%29%29) provide-spec ...)</td></tr><tr><td style="text-align: right;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: center;" data-valign="baseline">|</td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline">([for-label](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._for-label%29%29) provide-spec ...)</td></tr><tr><td style="text-align: right;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: center;" data-valign="baseline">|</td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline">([for-space](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._for-space%29%29) space provide-spec ...)</td></tr><tr><td style="text-align: right;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: center;" data-valign="baseline">|</td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline">derived-provide-spec</td></tr><tr><td style="text-align: right;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: center;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline"> </td></tr><tr><td style="text-align: right;" data-valign="baseline">phase-level</td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: center;" data-valign="baseline">=</td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline">exact-integer</td></tr><tr><td style="text-align: right;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: center;" data-valign="baseline">|</td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline">#f</td></tr><tr><td style="text-align: right;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: center;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline"> </td></tr><tr><td style="text-align: right;" data-valign="baseline">space</td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: center;" data-valign="baseline">=</td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline">id</td></tr><tr><td style="text-align: right;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: center;" data-valign="baseline">|</td><td style="text-align: left;" data-valign="baseline"> </td><td style="text-align: left;" data-valign="baseline">#f</td></tr></tbody></table></td></tr></tbody></table>

Declares exports from a module. A [provide](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._provide%29%29) form must appear in a [module context](syntax-model.html#%28tech._module._context%29) or a [module-begin context](syntax-model.html#%28tech._module._begin._context%29).

A provide-spec indicates one or more bindings to provide. For each exported binding, the external name is a symbol that can be different from the symbolic form of the identifier that is bound within the module. Also, each export is drawn from a particular [phase level](syntax-model.html#%28tech._phase._level%29) and exported at the same [phase level](syntax-model.html#%28tech._phase._level%29); by default, the relevant phase level is the number of [begin-for-syntax](begin.html#%28form._%28%28quote._~23~25kernel%29._begin-for-syntax%29%29) forms that enclose the [provide](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._provide%29%29) form. Finally, each export is drawn from a [binding space](syntax-model.html#%28tech._binding._space%29) and exported at the same [binding space](syntax-model.html#%28tech._binding._space%29).

The syntax of provide-spec can be extended by bindings to [provide transformers](stxtrans.html#%28tech._provide._transformer%29) or [provide pre-transformers](stxtrans.html#%28tech._provide._pre._transformer%29), such as via [define-provide-syntax](define.html#%28form._%28%28lib._racket%2Fprovide-syntax..rkt%29._define-provide-syntax%29%29), but the pre-defined forms are as follows.

> > |     |
> > |-----|
> > | id  |
>
> Exports id, which must be [bound](syntax-model.html#%28tech._bound%29) within the module (i.e., either defined or imported) at the relevant [phase level](syntax-model.html#%28tech._phase._level%29) and [binding space](syntax-model.html#%28tech._binding._space%29). The symbolic form of id is used as the external name, and the symbolic form of the defined or imported identifier must match (otherwise, the external name could be ambiguous).
>
>

>
> Examples:
>
>

>
>

>
> > ```racket
> > > ( module nest racket ( provide num-eggs ) ( define num-eggs 2 ) )
> > > ( require ' nest )
> > > num-eggs
> > 2
> > ```
>
>

>
> If id has a transformer binding to a [rename transformer](syntax-model.html#%28tech._rename._transformer%29), then the transformer affects the exported binding. See [make-rename-transformer](stxtrans.html#%28def._%28%28quote._~23~25kernel%29._make-rename-transformer%29%29) for more information.

>

>
> > <table data-cellpadding="0" data-cellspacing="0"><colgroup><col style="width: 100%" /></colgroup><tbody><tr><td><blockquote>

<p>syntax</p>

<p>([all-defined-out](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._all-defined-out%29%29))</p></blockquote></td></tr></tbody></table>
>
>

>
>

>
> Exports all identifiers that are defined at the relevant [phase level](syntax-model.html#%28tech._phase._level%29) within the exporting module, and that have the same lexical context as the ([all-defined-out](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._all-defined-out%29%29)) form, excluding bindings to [rename transformers](syntax-model.html#%28tech._rename._transformer%29) where the target identifier has the 'not-provide-all-defined [syntax property](stxprops.html#%28tech._syntax._property%29). The external name for each identifier is the symbolic form of the identifier. Only identifiers accessible from the lexical context of the ([all-defined-out](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._all-defined-out%29%29)) form are included; that is, macro-introduced imports are not re-exported, unless the ([all-defined-out](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._all-defined-out%29%29)) form was introduced at the same time.
>
>

>
>

>
> Examples:
>
>

>
>

>
> > ```racket
> > > ( module nest racket ( provide ( all-defined-out ) ) ( define num-eggs 2 ) )
> > > ( require ' nest )
> > > num-eggs
> > 2
> > ```
>
>

>

>
> > <table data-cellpadding="0" data-cellspacing="0"><colgroup><col style="width: 100%" /></colgroup><tbody><tr><td><blockquote>

<p>syntax</p>

<p>([all-from-out](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._all-from-out%29%29) module-path ...)</p></blockquote></td></tr></tbody></table>
>
>

>
>

>
> Exports all identifiers that are imported into the exporting module using a require-spec built on each module-path (see [Importing and Exporting: require and provide]()) with no [phase-level](syntax-model.html#%28tech._phase._level%29) shift. The symbolic name for export is derived from the name that is bound within the module, as opposed to the symbolic name of the export from each module-path. Only identifiers accessible from the lexical context of the module-path are included; that is, macro-introduced imports are not re-exported, unless the module-path was introduced at the same time.
>
>

>
>

>
> Examples:
>
>

>
>

>
> > ```racket
> > > ( module nest racket ( provide num-eggs ) ( define num-eggs 2 ) )
> > > ( module hen-house racket ( require ' nest ) ( provide ( all-from-out ' nest ) ) )
> > > ( require ' hen-house )
> > > num-eggs
> > 2
> > ```
>
>

>

>
> > <table data-cellpadding="0" data-cellspacing="0"><colgroup><col style="width: 100%" /></colgroup><tbody><tr><td><blockquote>

<p>syntax</p>

<p>([rename-out](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._rename-out%29%29) [orig-id export-id] ...)</p></blockquote></td></tr></tbody></table>
>
>

>
>

>
> Exports each orig-id, which must be [bound](syntax-model.html#%28tech._bound%29) within the module at the relevant [phase level](syntax-model.html#%28tech._phase._level%29) and [binding space](syntax-model.html#%28tech._binding._space%29). The symbolic name for each export is export-id instead of orig-id.
>
>

>
>

>
> Examples:
>
>

>
>

>
> > ```racket
> > > ( module nest racket ( provide ( rename-out [ count num-eggs ] ) ) ( define count 2 ) )
> > > ( require ' nest )
> > > num-eggs
> > 2
> > > count
> > count: undefined;
> > cannot reference an identifier before its definition
> > in module: top-level
> > ```
>
>

>

>
> > <table data-cellpadding="0" data-cellspacing="0"><colgroup><col style="width: 100%" /></colgroup><tbody><tr><td><blockquote>

<p>syntax</p>

<p>([except-out](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._except-out%29%29) provide-spec provide-spec ...)</p></blockquote></td></tr></tbody></table>
>
>

>
>

>
> Like the first provide-spec, but omitting the bindings listed in each subsequent provide-spec. If one of the latter bindings is not included in the initial provide-spec, a syntax error is reported. The symbolic export name information in the latter provide-specs is ignored; only the bindings are used.
>
>

>
>

>
> Examples:
>
>

>
>

>
> > ```racket
> > > ( module nest racket ( provide ( except-out ( all-defined-out ) num-chicks ) ) ( define num-eggs 2 ) ( define num-chicks 3 ) )
> > > ( require ' nest )
> > > num-eggs
> > 2
> > > num-chicks
> > num-chicks: undefined;
> > cannot reference an identifier before its definition
> > in module: top-level
> > ```
>
>

>

>
> > <table data-cellpadding="0" data-cellspacing="0"><colgroup><col style="width: 100%" /></colgroup><tbody><tr><td><blockquote>

<p>syntax</p>

<p>([prefix-out](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._prefix-out%29%29) prefix-id provide-spec)</p></blockquote></td></tr></tbody></table>
>
>

>
>

>
> Like provide-spec, but with each symbolic export name from provide-spec prefixed with prefix-id.
>
>

>
>

>
> Examples:
>
>

>
>

>
> > ```racket
> > > ( module nest racket ( provide ( prefix-out chicken: num-eggs ) ) ( define num-eggs 2 ) )
> > > ( require ' nest )
> > > chicken:num-eggs
> > 2
> > ```
>
>

>
> A [syntax property](stxprops.html#%28tech._syntax._property%29) with the key 'import-or-export-prefix-ranges is added to the exported identifier in the expanded form of [provide](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._provide%29%29).
>
> Changed in version 8.9.0.5 of package base: Added the 'import-or-export-prefix-ranges syntax property.

>

>
> > <table data-cellpadding="0" data-cellspacing="0"><colgroup><col style="width: 100%" /></colgroup><tbody><tr><td><blockquote>

<p>syntax</p>

<p>([struct-out](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct-out%29%29) id)</p></blockquote></td></tr></tbody></table>
>
>

>
>

>
> Exports the bindings associated with a structure type id. Typically, id is bound with ([struct](define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29) id ....); more generally, id must have a [transformer](syntax-model.html#%28tech._transformer%29) binding of structure-type information at the relevant [phase level](syntax-model.html#%28tech._phase._level%29); see [Structure Type Transformer Binding](structinfo.html). Furthermore, for each identifier mentioned in the structure-type information, the enclosing module must define or import one identifier that is [free-identifier=?](stxcmp.html#%28def._%28%28quote._~23~25kernel%29._free-identifier~3d~3f%29%29). If the structure-type information includes a super-type identifier, and if the identifier has a [transformer](syntax-model.html#%28tech._transformer%29) binding of structure-type information, the accessor and mutator bindings of the super-type are not included by [struct-out](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct-out%29%29) for export.
>
>

>
>

>
> Examples:
>
>

>
>

>
> > ```racket
> > > ( module nest racket ( provide ( struct-out egg ) ) ( struct egg ( color wt ) ) )
> > > ( require ' nest )
> > > ( egg-color ( egg ' blue 10 ) )
> > 'blue
> > ```
>
>

>

>
> > <table data-cellpadding="0" data-cellspacing="0"><colgroup><col style="width: 100%" /></colgroup><tbody><tr><td><blockquote>

<p>syntax</p>

<p>([combine-out](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._combine-out%29%29) provide-spec ...)</p></blockquote></td></tr></tbody></table>
>
>

>
>

>
> The union of the provide-specs.
>
>

>
>

>
> Examples:
>
>

>
>

>
> > ```racket
> > > ( module nest racket ( provide ( combine-out num-eggs num-chicks ) ) ( define num-eggs 2 ) ( define num-chicks 1 ) )
> > > ( require ' nest )
> > > num-eggs
> > 2
> > > num-chicks
> > 1
> > ```
>
>

>

>
> > <table data-cellpadding="0" data-cellspacing="0"><colgroup><col style="width: 100%" /></colgroup><tbody><tr><td><blockquote>

<p>syntax</p>

<p>([protect-out](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._protect-out%29%29) provide-spec ...)</p></blockquote></td></tr></tbody></table>
>
>

>
>

>
> Like the union of the provide-specs, except that the exports are [protected](modprotect.html#%28tech._protected%29): requiring modules may refer to these bindings, but may not extract these bindings from macro expansions or access them via [eval](eval.html#%28def._%28%28quote._~23~25kernel%29._eval%29%29) without access privileges. For more details, see [Code Inspectors](modprotect.html). The provide-spec must specify only bindings that are defined within the exporting module.
>
>

>
>

>
> Examples:
>
>

>
>

>
> > ```racket
> > > ( module nest racket ( provide num-eggs ( protect-out num-chicks ) ) ( define num-eggs 2 ) ( define num-chicks 3 ) )
> > > ( define weak-inspector ( make-inspector ( current-code-inspector ) ) )
> > > ( define ( weak-eval x ) ( parameterize ( [ current-code-inspector weak-inspector ] ) ( define weak-ns ( make-base-namespace ) ) ( namespace-attach-module ( current-namespace ) ' ' nest weak-ns ) ( parameterize ( [ current-namespace weak-ns ] ) ( namespace-require ' ' nest ) ( eval x ) ) ) )
> > > ( require ' nest )
> > > ( list num-eggs num-chicks )
> > '(2 3)
> > > ( weak-eval ' num-eggs )
> > 2
> > > ( weak-eval ' num-chicks )
> > ?: access disallowed by code inspector to protected variable
> > from module: 'nest
> > at: num-chicks
> > ```
>
>

>
> See also [Code Inspectors for Trusted and Untrusted Code](https://plt.cs.northwestern.edu/new-snapshots/new-snapshots/doc/local-redirect/index.html?doc=guide&rel=code-inspectors_protect.html&version=8.18.0.13).

> > |                                                                                |
> > |-----------------------------------------------------------------------------------------------------------------------------------------------|
> > | ([for-meta](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._for-meta%29%29) phase-level provide-spec ...) |
>
> Like the union of the provide-specs, but adjusted to apply to the [phase level](syntax-model.html#%28tech._phase._level%29) specified by phase-level relative to the current phase level (where #f corresponds to the [label phase level](syntax-model.html#%28tech._label._phase._level%29)). In particular, an id or [rename-out](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._rename-out%29%29) form as a provide-spec refers to a binding at phase-level relative to the current level, an [all-defined-out](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._all-defined-out%29%29) exports only definitions at phase-level relative to the current phase level, and an [all-from-out](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._all-from-out%29%29) exports bindings imported with a shift by phase-level.
>
>

>
> Examples:
>
>

>
>

>
> > ```racket
> > > ( module nest racket ( begin-for-syntax ( define eggs 2 ) ) ( define chickens 3 ) ( provide ( for-syntax eggs ) chickens ) )
> > > ( require ' nest )
> > > ( define-syntax ( test-eggs stx ) ( printf "Eggs are ~a\n" eggs ) #' 0 )
> > > ( test-eggs )
> > Eggs are 2
> > 0
> > > chickens
> > 3
> > > ( module broken-nest racket ( define eggs 2 ) ( define chickens 3 ) ( provide ( for-syntax eggs ) chickens ) )
> > eval:7:0: provide: provided identifier is not defined or
> > required
> > at: eggs
> > in: (provide (for-syntax eggs) chickens)
> > > ( module nest2 racket ( begin-for-syntax ( define eggs 2 ) ) ( provide ( for-syntax eggs ) ) )
> > > ( require ( for-meta 2 racket/base ) ( for-syntax ' nest2 ) )
> > > ( define-syntax ( test stx ) ( define-syntax ( show-eggs stx ) ( printf "Eggs are ~a\n" eggs ) #' 0 ) ( begin ( show-eggs ) #' 0 ) )
> > Eggs are 2
> > > ( test )
> > 0
> > ```
>
>

> > |                                                                                |
> > |---------------------------------------------------------------------------------------------------------------------------------------|
> > | ([for-syntax](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._for-syntax%29%29) provide-spec ...) |
>
> Same as ([for-meta](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._for-meta%29%29) 1 provide-spec [...](stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29)).

> > |                                                                                |
> > |-------------------------------------------------------------------------------------------------------------------------------------------|
> > | ([for-template](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._for-template%29%29) provide-spec ...) |
>
> Same as ([for-meta](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._for-meta%29%29) -1 provide-spec [...](stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29)).

> > |                                                                                |
> > |-------------------------------------------------------------------------------------------------------------------------------------|
> > | ([for-label](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._for-label%29%29) provide-spec ...) |
>
> Same as ([for-meta](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._for-meta%29%29) #f provide-spec [...](stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29)).

> > |                                                                                |
> > |-------------------------------------------------------------------------------------------------------------------------------------------|
> > | ([for-space](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._for-space%29%29) space provide-spec ...) |
>
> Like the union of the provide-specs, but adjusted to apply to the [binding space](syntax-model.html#%28tech._binding._space%29) specified by space—where space is either an identifier or #f for the [default binding space](syntax-model.html#%28tech._default._binding._space%29). In particular, an id or [rename-out](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._rename-out%29%29) form as a provide-spec refers to a binding in space, an [all-defined-out](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._all-defined-out%29%29) exports only definitions in space, and an [all-from-out](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._all-from-out%29%29) exports bindings imported into space.
>
> When providing a binding for a non-default binding space, normally a module should also provide a binding for the default binding space, where the default-space binding represents the intended meaning of the identifier. When a module later imports the same name in different spaces from modules that adhere to this convention, then if the two modules also (re)export the same binding for the name in the default space, the imports are likely consistent. If the two modules export different bindings for the name in the default space, then attempting to import both modules will trigger an error about conflicting imports, and a programmer can explicitly resolve the mismatch.
>
> Added in version 8.2.0.3 of package base.

> > |                      |
> > |----------------------|
> > | derived-provide-spec |
>
> See [define-provide-syntax](define.html#%28form._%28%28lib._racket%2Fprovide-syntax..rkt%29._define-provide-syntax%29%29) for information on expanding the set of provide-spec forms.

Each export specified within a module must have a distinct symbolic export name, though the same binding can be specified with the multiple symbolic names.

>
<colgroup><col style="width: 100%" /></colgroup>

syntax

([for-meta](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._for-meta%29%29) phase-level require-spec ...)

See [require](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) and [provide](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._provide%29%29).

>
<colgroup><col style="width: 100%" /></colgroup>

syntax

([for-syntax](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._for-syntax%29%29) require-spec ...)

See [require](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) and [provide](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._provide%29%29).

>
<colgroup><col style="width: 100%" /></colgroup>

syntax

([for-template](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._for-template%29%29) require-spec ...)

See [require](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) and [provide](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._provide%29%29).

>
<colgroup><col style="width: 100%" /></colgroup>

syntax

([for-label](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._for-label%29%29) require-spec ...)

See [require](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) and [provide](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._provide%29%29).

>
<colgroup><col style="width: 100%" /></colgroup>

syntax

([for-space](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._for-space%29%29) space require-spec ...)

See [require](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) and [provide](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._provide%29%29).

>
<colgroup><col style="width: 100%" /></colgroup>

syntax

([#%require](#%28form._%28%28quote._~23~25kernel%29._~23~25require%29%29) raw-require-spec ...)

<colgroup><col style="width: 20%" /><col style="width: 20%" /><col style="width: 20%" /><col style="width: 20%" /><col style="width: 20%" /></colgroup>

raw-require-spec	 	=	 	phaseless-spec

 	 	|	 	(for-meta phase-level raw-require-spec ...)

 	 	|	 	(for-syntax raw-require-spec ...)

 	 	|	 	(for-template raw-require-spec ...)

 	 	|	 	(for-label raw-require-spec ...)

 	 	|	 	(just-meta phase-level raw-require-spec ...)

 	 	|	 	(portal portal-id content)

phase-level	 	=	 	exact-integer

 	 	|	 	#f

phaseless-spec	 	=	 	spaceless-spec

 	 	|	 	(for-space space phaseless-spec ...)

 	 	|	 	(just-space space spaceless-spec ...)

space	 	=	 	id

 	 	|	 	#f

spaceless-spec	 	=	 	raw-module-path

 	 	|	 	(only raw-module-path id ...)

 	 	|	 	(prefix prefix-id raw-module-path)

 	 	|	 	(all-except raw-module-path id ...)

 	 	|
( prefix-all-except prefix-id
> raw-module-path id ... )

 	 	|	 	(rename raw-module-path local-id exported-id)

raw-module-path	 	=	 	raw-root-module-path

 	 	|	 	(submod raw-root-module-path id ...+)

 	 	|	 	(submod "." id ...+)

raw-root-module-path	 	=	 	(quote id)

 	 	|	 	rel-string

 	 	|	 	(lib rel-string ...)

 	 	|	 	id

 	 	|	 	(file string)

 	 	|
( planet rel-string
> ( user-string pkg-string vers ... ) )

 	 	|	 	literal-path

The primitive import form, to which [require](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) expands. A raw-require-spec is similar to a require-spec in a [require](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) form, except that the syntax is more constrained, not composable, and not extensible. Also, sub-form names like for-syntax and lib are recognized symbolically, instead of via bindings. Some nested constraints are not formalized in the grammar above:

-   a just-meta form cannot appear within a just-meta form;

-   a for-meta, for-syntax, for-template, or for-label form cannot appear within a for-meta, for-syntax, for-template, or for-label form; and

-   a for-space form cannot appear within a for-space form.

-   a portal form cannot appear within a just-meta form.

Except for the portal form, each raw-require-spec corresponds to the obvious require-spec, but the rename sub-form has the identifiers in reverse order compared to [rename-in](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._rename-in%29%29).

For most raw-require-specs, the lexical context of the raw-require-spec determines the context of introduced identifiers. The exception is the rename sub-form, where the lexical context of the local-id is preserved.

A literal-path as a raw-root-module-path corresponds to a path in the sense of [path?](Manipulating_Paths.html#%28def._%28%28quote._~23~25kernel%29._path~3f%29%29). Since path values are never produced by [read-syntax](Reading.html#%28def._%28%28quote._~23~25kernel%29._read-syntax%29%29), they appear only in programmatically constructed expressions. They also appear naturally as arguments to functions such as [namespace-require](Namespaces.html#%28def._%28%28quote._~23~25kernel%29._namespace-require%29%29), with otherwise take a quoted raw-module-spec.

The portal form provides a way to define [portal syntax](stxtrans.html#%28tech._portal._syntax%29) at any phase level. A (portal portal-id content), defines portal-id to portal syntax with content effectively quoted to serve as its content.

Changed in version 8.2.0.3 of package base: Added for-space and just-space.
Changed in version 8.3.0.8: Added portal.

>
<colgroup><col style="width: 100%" /></colgroup>

syntax

([#%provide](#%28form._%28%28quote._~23~25kernel%29._~23~25provide%29%29) raw-provide-spec ...)

raw-provide-spec	 	=	 	phaseless-spec

 	 	|	 	(for-meta phase-level phaseless-spec ...)

 	 	|	 	(for-syntax phaseless-spec ...)

 	 	|	 	(for-label phaseless-spec ...)

 	 	|	 	(protect raw-provide-spec ...)

phase-level	 	=	 	exact-integer

 	 	|	 	#f

phaseless-spec	 	=	 	spaceless-spec

 	 	|	 	(for-space space spaceless-spec ...)

 	 	|	 	(protect phaseless-spec ...)

space	 	=	 	id

 	 	|	 	#f

spaceless-spec	 	=	 	id

 	 	|	 	(rename local-id export-id)

 	 	|	 	(struct struct-id (field-id ...))

 	 	|	 	(all-from raw-module-path)

 	 	|	 	(all-from-except raw-module-path id ...)

 	 	|	 	(all-defined)

 	 	|	 	(all-defined-except id ...)

 	 	|	 	(prefix-all-defined prefix-id)

 	 	|	 	(prefix-all-defined-except prefix-id id ...)

 	 	|	 	(protect spaceless-spec ...)

 	 	|	 	(expand (id . datum))

 	 	|	 	(expand (id . datum) orig-form)

The primitive export form, to which [provide](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._provide%29%29) expands. A raw-module-path is as for [#%require](#%28form._%28%28quote._~23~25kernel%29._~23~25require%29%29). A protect sub-form cannot appear within a protect sub-form.

Like [#%require](#%28form._%28%28quote._~23~25kernel%29._~23~25require%29%29), the sub-form keywords for [#%provide](#%28form._%28%28quote._~23~25kernel%29._~23~25provide%29%29) are recognized symbolically, and nearly every raw-provide-spec has an obvious equivalent provide-spec via [provide](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._provide%29%29), with the exception of the struct and expand sub-forms.

A (struct struct-id (field-id [...](stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29))) sub-form expands to struct-id, make-struct-id, struct:struct-id, struct-id?, struct-id-field-id for each field-id, and set-struct-id-field-id! for each field-id. The lexical context of the struct-id is used for all generated identifiers.

Unlike [#%require](#%28form._%28%28quote._~23~25kernel%29._~23~25require%29%29), the [#%provide](#%28form._%28%28quote._~23~25kernel%29._~23~25provide%29%29) form is macro-extensible via an explicit expand sub-form; the (id . datum) part is locally expanded as an expression (even though it is not actually an expression), stopping when a [begin](begin.html#%28form._%28%28quote._~23~25kernel%29._begin%29%29) form is produced; if the expansion result is ([begin](begin.html#%28form._%28%28quote._~23~25kernel%29._begin%29%29) raw-provide-spec [...](stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29)), it is spliced in place of the expand form, otherwise a syntax error is reported. If an orig-form part is provided, then it is used instead of the [#%provide](#%28form._%28%28quote._~23~25kernel%29._~23~25provide%29%29) form when raising syntax errors, such as a “provide identifier is not defined” error. The expand sub-form is not normally used directly; it provides a hook for implementing [provide](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._provide%29%29) and [provide transformers](stxtrans.html#%28tech._provide._transformer%29).

The all-from and all-from-except forms re-export only identifiers that are accessible in lexical context of the all-from or all-from-except form itself. That is, macro-introduced imports are not re-exported, unless the all-from or all-from-except form was introduced at the same time. Similarly, all-defined and its variants export only definitions accessible from the lexical context of the spaceless-spec form.

Changed in version 8.2.0.3 of package base: Added for-space.
Changed in version 8.2.0.5: Added orig-form support to expand.

#### 3.2.1 Additional [require](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) Forms

|                                                                                |                                                                                |
|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------:|
|  ([require](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) [racket/require](#%28mod-path._racket%2Frequire%29)) |  package: [base](https://pkgs.racket-lang.org/package/base "Install this package using `raco pkg install base`") |

The bindings documented in this section are provided by the [racket/require](#%28mod-path._racket%2Frequire%29) library, not [racket/base](index.html) or [racket](index.html).

The following forms support more complex selection and manipulation of sets of imported identifiers.

>
<colgroup><col style="width: 100%" /></colgroup>

syntax

([matching-identifiers-in](#%28form._%28%28lib._racket%2Frequire..rkt%29._matching-identifiers-in%29%29) regexp require-spec)

Like require-spec, but including only imports whose names match regexp. The regexp must be a literal regular expression (see [Regular Expressions](regexp.html)).

Examples:

> ```racket
> > ( module zoo racket/base ( provide tunafish swordfish blowfish monkey lizard ant ) ( define tunafish 1 ) ( define swordfish 2 ) ( define blowfish 3 ) ( define monkey 4 ) ( define lizard 5 ) ( define ant 6 ) )
> > ( require racket/require )
> > ( require ( matching-identifiers-in #rx"\\w*fish" ' zoo ) )
> > tunafish
> 1
> > swordfish
> 2
> > blowfish
> 3
> > monkey
> monkey: undefined;
> cannot reference an identifier before its definition
> in module: top-level
> ```

>
<colgroup><col style="width: 100%" /></colgroup>

syntax

([subtract-in](#%28form._%28%28lib._racket%2Frequire..rkt%29._subtract-in%29%29) require-spec subtracted-spec ...)

Like require-spec, but omitting those imports that would be imported by one of the subtracted-specs.

Examples:

> ```racket
> > ( module earth racket ( provide land sea air ) ( define land 1 ) ( define sea 2 ) ( define air 3 ) )
> > ( module mars racket ( provide aliens ) ( define aliens 4 ) )
> > ( module solar-system racket ( require ' earth ' mars ) ( provide ( all-from-out ' earth ) ( all-from-out ' mars ) ) )
> > ( require racket/require )
> > ( require ( subtract-in ' solar-system ' earth ) )
> > land
> land: undefined;
> cannot reference an identifier before its definition
> in module: top-level
> > aliens
> 4
> ```

>
<colgroup><col style="width: 100%" /></colgroup>

syntax

([filtered-in](#%28form._%28%28lib._racket%2Frequire..rkt%29._filtered-in%29%29) proc-expr require-spec)

Applies an arbitrary transformation on the import names (as strings) of require-spec. The proc-expr must evaluate at expansion time to a single-argument procedure, which is applied on each of the names from require-spec. For each name, the procedure must return either a string for the import’s new name or #f to exclude the import.

> > > The second part of [filtered-in](#%28form._%28%28lib._racket%2Frequire..rkt%29._filtered-in%29%29) is expand-time code evaluated in the scope of the enclosing module. Accordingly, most uses need ([require](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) ([for-syntax](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._for-syntax%29%29) racket/base)) if [racket/base](index.html) is not already imported [for-syntax](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._for-syntax%29%29). For example, [#lang](https://plt.cs.northwestern.edu/new-snapshots/new-snapshots/doc/local-redirect/index.html?doc=guide&rel=Module_Syntax.html%23%2528part._hash-lang%2529&version=8.18.0.13) [racket](index.html) establishes this import automatically, while [#lang](https://plt.cs.northwestern.edu/new-snapshots/new-snapshots/doc/local-redirect/index.html?doc=guide&rel=Module_Syntax.html%23%2528part._hash-lang%2529&version=8.18.0.13) [racket/base](index.html) does not.

For example,

> ```racket
> ( require ( filtered-in
> ( lambda ( name )
> ( and ( regexp-match? #rx"^[a-z-]+$" name )
> ( regexp-replace #rx"-" ( string-titlecase name ) "" ) ) )
> racket/base ) )
> ```

imports only bindings from [racket/base](index.html) that match the pattern #rx"^\[a-z-\]+$", and it converts the names to “camel case.”

>
<colgroup><col style="width: 100%" /></colgroup>

syntax

([path-up](#%28form._%28%28lib._racket%2Frequire..rkt%29._path-up%29%29) rel-string ...)

Specifies paths to modules named by the rel-strings similar to using the rel-strings directly, except that if a required module file is not found relative to the enclosing source, it is searched for in the parent directory, and then in the grand-parent directory, etc., all the way to the root directory. The discovered path relative to the enclosing source becomes part of the expanded form.

This form is useful in setting up a “project environment.” For example, using the following "config.rkt" file in the root directory of your project:

> ```racket
> #lang racket/base
> ( require racket/require-syntax
> ( for-syntax "utils/in-here.rkt" ) )
> ( provide utils-in )
> ( define-require-syntax utils-in in-here-transformer )
> ```

and using "utils/in-here.rkt" under the same root directory:

> ```racket
> #lang racket/base
> ( require racket/runtime-path )
> ( provide in-here-transformer )
> ( define-runtime-path here "." )
> ( define ( in-here-transformer stx )
> ( syntax-case stx ( )
> [ ( _ sym )
> ( identifier? #' sym )
> ( let ( [ path ( build-path here ( format "~a.rkt" ( syntax-e #' sym ) ) ) ] )
> ( datum->syntax stx ` ( file , ( path->string path ) ) stx ) ) ] ) )
> ```

then [path-up](#%28form._%28%28lib._racket%2Frequire..rkt%29._path-up%29%29) works for any other module under the project directory to find "config.rkt":

> ```racket
> ( require racket/require
> ( path-up "config.rkt" )
> ( utils-in foo ) )
> ```

Note that the order of requires in the example is important, as each of the first two bind the identifier used in the following.

An alternative in this scenario is to use [path-up](#%28form._%28%28lib._racket%2Frequire..rkt%29._path-up%29%29) directly to find the utility module:

> ```racket
> ( require racket/require
> ( path-up "utils/foo.rkt" ) )
> ```

but then sub-directories that are called "utils" override the one in the project’s root. In other words, the previous method requires only a single unique name.

>
<colgroup><col style="width: 100%" /></colgroup>

syntax

([multi-in](#%28form._%28%28lib._racket%2Frequire..rkt%29._multi-in%29%29) subs ...+)

subs	 	=	 	sub-path

 	 	|	 	(sub-path ...)

sub-path	 	=	 	rel-string

 	 	|	 	id

Specifies multiple files to be required from a hierarchy of directories or collections. The set of required module paths is computed as the Cartesian product of the subs groups, where each sub-path is combined with other sub-paths in order using a / separator. A sub-path as a subs is equivalent to (sub-path). All sub-paths in a given [multi-in](#%28form._%28%28lib._racket%2Frequire..rkt%29._multi-in%29%29) form must be either strings or identifiers.

Examples:

<colgroup><col style="width: 100%" /></colgroup>

([require](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) ([multi-in](#%28form._%28%28lib._racket%2Frequire..rkt%29._multi-in%29%29) racket (dict list)))

   is equivalent to
	([require](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) racket/dict racket/list)

([require](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) ([multi-in](#%28form._%28%28lib._racket%2Frequire..rkt%29._multi-in%29%29) "math" "matrix" "utils.rkt"))

   is equivalent to
	([require](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) "math/matrix/utils.rkt")

([require](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) ([multi-in](#%28form._%28%28lib._racket%2Frequire..rkt%29._multi-in%29%29) "utils" ("math.rkt" "matrix.rkt")))

   is equivalent to
	([require](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) "utils/math.rkt" "utils/matrix.rkt")

([require](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) ([multi-in](#%28form._%28%28lib._racket%2Frequire..rkt%29._multi-in%29%29) ("math" "matrix") "utils.rkt"))

   is equivalent to
	([require](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) "math/utils.rkt" "matrix/utils.rkt")

([require](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) ([multi-in](#%28form._%28%28lib._racket%2Frequire..rkt%29._multi-in%29%29) ("math" "matrix") ("utils.rkt" "helpers.rkt")))

<colgroup><col style="width: 50%" /><col style="width: 50%" /></colgroup>

   is equivalent to

( require "math/utils.rkt" "math/helpers.rkt"
"matrix/utils.rkt" "matrix/helpers.rkt" )

#### 3.2.2 Additional [provide](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._provide%29%29) Forms

|                                                                                |                                                                                |
|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------:|
|  ([require](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) [racket/provide](#%28mod-path._racket%2Fprovide%29)) |  package: [base](https://pkgs.racket-lang.org/package/base "Install this package using `raco pkg install base`") |

The bindings documented in this section are provided by the [racket/provide](#%28mod-path._racket%2Fprovide%29) library, not [racket/base](index.html) or [racket](index.html).

>
<colgroup><col style="width: 100%" /></colgroup>

syntax

([matching-identifiers-out](#%28form._%28%28lib._racket%2Fprovide..rkt%29._matching-identifiers-out%29%29) regexp provide-spec)

Like provide-spec, but including only exports of bindings with an external name that matches regexp. The regexp must be a literal regular expression (see [Regular Expressions](regexp.html)).

>
<colgroup><col style="width: 100%" /></colgroup>

syntax

([filtered-out](#%28form._%28%28lib._racket%2Fprovide..rkt%29._filtered-out%29%29) proc-expr provide-spec)

Analogous to [filtered-in](#%28form._%28%28lib._racket%2Frequire..rkt%29._filtered-in%29%29), but for filtering and renaming exports.

> > > See the documentation of [filtered-in](#%28form._%28%28lib._racket%2Frequire..rkt%29._filtered-in%29%29) for use with [#lang](https://plt.cs.northwestern.edu/new-snapshots/new-snapshots/doc/local-redirect/index.html?doc=guide&rel=Module_Syntax.html%23%2528part._hash-lang%2529&version=8.18.0.13) [racket/base](index.html).

For example,

> ```racket
> ( provide ( filtered-out
> ( lambda ( name )
> ( and ( regexp-match? #rx"^[a-z-]+$" name )
> ( regexp-replace
> #rx"-" ( string-titlecase name ) "" ) ) )
> ( all-defined-out ) ) )
> ```

exports only bindings that match the pattern #rx"^\[a-z-\]+$", and it converts the names to “camel case.”

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

# 3.3 Literals: quote and #%datum

### 3.3 Literals: [quote](#%28form._%28%28quote._~23~25kernel%29._quote%29%29) and [#%datum](#%28form._%28%28quote._~23~25kernel%29._~23~25datum%29%29)

Many forms are implicitly quoted (via [#%datum](#%28form._%28%28quote._~23~25kernel%29._~23~25datum%29%29)) as literals. See [Expansion Steps](syntax-model.html#%28part._expand-steps%29) for more information.

> > > [Quoting: quote and ’](https://plt.cs.northwestern.edu/new-snapshots/new-snapshots/doc/local-redirect/index.html?doc=guide&rel=quote.html&version=8.18.0.13) in [The Racket Guide](https://plt.cs.northwestern.edu/new-snapshots/new-snapshots/doc/local-redirect/index.html?doc=guide&rel=index.html&version=8.18.0.13) introduces [quote](#%28form._%28%28quote._~23~25kernel%29._quote%29%29).

>
<colgroup><col style="width: 100%" /></colgroup>

syntax

([quote](#%28form._%28%28quote._~23~25kernel%29._quote%29%29) datum)

Produces a constant value corresponding to datum (i.e., the representation of the program fragment) without its [lexical information](syntax-model.html#%28tech._lexical._information%29), source location, etc. Quoted pairs, vectors, and boxes are immutable.

Examples:

> ```racket
> > ( quote x )
> 'x
> > ( quote ( + 1 2 ) )
> '(+ 1 2)
> > ( + 1 2 )
> 3
> ```

>
<colgroup><col style="width: 100%" /></colgroup>

syntax

([#%datum](#%28form._%28%28quote._~23~25kernel%29._~23~25datum%29%29) . datum)

Expands to (quote datum), as long as datum is not a keyword. If datum is a keyword, a syntax error is reported.

See also [Expansion Steps](syntax-model.html#%28part._expand-steps%29) for information on how the expander introduces #%datum identifiers.

Examples:

> ```racket
> > ( #%datum . 10 )
> 10
> > ( #%datum . x )
> 'x
> > ( #%datum . #:x )
> eval:6:0: #%datum: keyword misused as an expression
> at: #:x
> ```

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

# 3.4 Expression Wrapper: #%expression

### 3.4 Expression Wrapper: [#%expression](#%28form._%28%28quote._~23~25kernel%29._~23~25expression%29%29)

>
<colgroup><col style="width: 100%" /></colgroup>

syntax

([#%expression](#%28form._%28%28quote._~23~25kernel%29._~23~25expression%29%29) expr)

Produces the same result as expr. Using [#%expression](#%28form._%28%28quote._~23~25kernel%29._~23~25expression%29%29) forces the parsing of a form as an expression.

Examples:

> ```racket
> > ( #%expression ( + 1 2 ) )
> 3
> > ( #%expression ( define x 10 ) )
> eval:8:0: define: not allowed in an expression context
> in: (define x 10)
> ```

The [#%expression](#%28form._%28%28quote._~23~25kernel%29._~23~25expression%29%29) form is helpful in recursive definition contexts where expanding a subsequent definition can provide compile-time information for the current expression. For example, consider a define-sym-case macro that simply records some symbols at compile-time in a given identifier.

> ```racket
> ( define-syntax ( define-sym-case stx ) ( syntax-case stx ( ) [ ( _ id sym ... ) ( andmap identifier? ( syntax->list #' ( sym ... ) ) ) #' ( define-syntax id ' ( sym ... ) ) ] ) )
> ```

and then a variant of [case](case.html#%28form._%28%28lib._racket%2Fprivate%2Fmore-scheme..rkt%29._case%29%29) that checks to make sure the symbols used in the expression match those given in the earlier definition:

> ```racket
> ( define-syntax ( sym-case stx ) ( syntax-case stx ( ) [ ( _ id val-expr [ ( sym ) expr ] ... ) ( let ( ) ( define expected-ids ( syntax-local-value #' id ( λ ( ) ( raise-syntax-error ' sym-case "expected an identifier bound via define-sym-case" stx #' id ) ) ) ) ( define actual-ids ( syntax->datum #' ( sym ... ) ) ) ( unless ( equal? expected-ids actual-ids ) ( raise-syntax-error ' sym-case ( format "expected the symbols ~s" expected-ids ) stx ) ) #' ( case val-expr [ ( sym ) expr ] ... ) ) ] ) )
> ```

If the definition follows the use like this, then the define-sym-case macro does not have a chance to bind [id](https://plt.cs.northwestern.edu/new-snapshots/new-snapshots/doc/local-redirect/index.html?doc=syntax&rel=Library_Syntax_Classes_and_Literal_Sets.html%23%2528form._%2528%2528lib._syntax%252Fparse..rkt%2529._id%2529%2529&version=8.18.0.13) and the sym-case macro signals an error:

> ```racket
> > ( let ( ) ( sym-case land-creatures ' bear [ ( bear ) 1 ] [ ( fox ) 2 ] ) ( define-sym-case land-creatures bear fox ) )
> eval:11:0: sym-case: expected an identifier bound via
> define-sym-case
> at: land-creatures
> in: (sym-case land-creatures (quote bear) ((bear) 1)
> ((fox) 2))
> ```

But if the sym-case is wrapped in an [#%expression](#%28form._%28%28quote._~23~25kernel%29._~23~25expression%29%29), then the expander does not need to expand it to know it is an expression and it moves on to the define-sym-case expression.

> ```racket
> > ( let ( ) ( #%expression ( sym-case sea-creatures ' whale [ ( whale ) 1 ] [ ( squid ) 2 ] ) ) ( define-sym-case sea-creatures whale squid ) ' more... )
> 'more...
> ```

Of course, a macro like sym-case should not require its clients to add [#%expression](#%28form._%28%28quote._~23~25kernel%29._~23~25expression%29%29); instead it should check the basic shape of its arguments and then expand to [#%expression](#%28form._%28%28quote._~23~25kernel%29._~23~25expression%29%29) wrapped around a helper macro that calls [syntax-local-value](stxtrans.html#%28def._%28%28quote._~23~25kernel%29._syntax-local-value%29%29) and finishes the expansion.

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

# 3.5 Variable References and #%top

### 3.5 Variable References and [#%top](#%28form._%28%28quote._~23~25kernel%29._~23~25top%29%29)

>
<colgroup><col style="width: 100%" /></colgroup>

syntax

id

Refers to a top-level, module-level, or local binding, when id is not bound as a transformer (see [Expansion](syntax-model.html#%28part._expansion%29)). At run-time, the reference evaluates to the value in the [location](eval-model.html#%28tech._location%29) associated with the binding.

When the expander encounters an id that is not bound by a module-level or local binding, it converts the expression to (#%top . id) giving #%top the lexical context of the id; typically, that context refers to [#%top](#%28form._%28%28quote._~23~25kernel%29._~23~25top%29%29). See also [Expansion Steps](syntax-model.html#%28part._expand-steps%29).

Examples:

> ```racket
> > ( define x 10 )
> > x
> 10
> > ( let ( [ x 5 ] ) x )
> 5
> > ( ( lambda ( x ) x ) 2 )
> 2
> ```

>
<colgroup><col style="width: 100%" /></colgroup>

syntax

([#%top](#%28form._%28%28quote._~23~25kernel%29._~23~25top%29%29) . id)

Equivalent to id when id is bound to a module-level or top-level variable. In a top-level context, ([#%top](#%28form._%28%28quote._~23~25kernel%29._~23~25top%29%29) . id) always refers to a top-level variable, even if id is [unbound](syntax-model.html#%28tech._unbound%29) or bound to syntax, as long as id does not have a local binding. In all contexts, ([#%top](#%28form._%28%28quote._~23~25kernel%29._~23~25top%29%29) . id) is a syntax error if id has a local binding.

Within a [module](module.html#%28form._%28%28quote._~23~25kernel%29._module%29%29) form, ([#%top](#%28form._%28%28quote._~23~25kernel%29._~23~25top%29%29) . id) expands to just id as long as id is defined within the module and has no local binding in its context. At [phase level](syntax-model.html#%28tech._phase._level%29) 0, ([#%top](#%28form._%28%28quote._~23~25kernel%29._~23~25top%29%29) . id) is an immediate syntax error if id is not bound. At [phase level](syntax-model.html#%28tech._phase._level%29) 1 and higher, a syntax error is reported if id is not defined at the corresponding phase by the end of [module](module.html#%28form._%28%28quote._~23~25kernel%29._module%29%29)-body [partial expansion](syntax-model.html#%28tech._partial._expansion%29).

See also [Expansion Steps](syntax-model.html#%28part._expand-steps%29) for information on how the expander introduces #%top identifiers.

Examples:

> ```racket
> > ( define x 12 )
> > ( #%top . x )
> 12
> ```

Changed in version 6.3 of package base: Changed the introduction of [#%top](#%28form._%28%28quote._~23~25kernel%29._~23~25top%29%29) in a top-level context to [unbound](syntax-model.html#%28tech._unbound%29) identifiers only.
Changed in version 8.2.0.7: Changed treatment of locally bound id to always report a syntax error, even outside of a module.

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

# 3.6 Locations: #%variable-reference

### 3.6 Locations: [#%variable-reference](#%28form._%28%28quote._~23~25kernel%29._~23~25variable-reference%29%29)

>
<colgroup><col style="width: 100%" /></colgroup>

syntax

([#%variable-reference](#%28form._%28%28quote._~23~25kernel%29._~23~25variable-reference%29%29) id)

([#%variable-reference](#%28form._%28%28quote._~23~25kernel%29._~23~25variable-reference%29%29) ([#%top](__top.html#%28form._%28%28quote._~23~25kernel%29._~23~25top%29%29) . id))

([#%variable-reference](#%28form._%28%28quote._~23~25kernel%29._~23~25variable-reference%29%29))

Produces an opaque variable reference value representing the [location](eval-model.html#%28tech._location%29) of id, which must be bound as a variable. If no id is supplied, the resulting value refers to an “anonymous” variable defined within the enclosing context (i.e., within the enclosing module, or at the top level if the form is not inside a module).

When ([#%top](__top.html#%28form._%28%28quote._~23~25kernel%29._~23~25top%29%29) . id) is used, then the variable reference refers to the same variable as ([#%top](__top.html#%28form._%28%28quote._~23~25kernel%29._~23~25top%29%29) . id). Note that ([#%top](__top.html#%28form._%28%28quote._~23~25kernel%29._~23~25top%29%29) . id) is not allowed if id is locally bound or within a module if id is bound as a transformer.

A [variable reference](#%28tech._variable._reference%29) can be used with [variable-reference->empty-namespace](Namespaces.html#%28def._%28%28quote._~23~25kernel%29._variable-reference-~3eempty-namespace%29%29), [variable-reference->resolved-module-path](Namespaces.html#%28def._%28%28quote._~23~25kernel%29._variable-reference-~3eresolved-module-path%29%29), and [variable-reference->namespace](Namespaces.html#%28def._%28%28quote._~23~25kernel%29._variable-reference-~3enamespace%29%29), but facilities like [define-namespace-anchor](Namespaces.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define-namespace-anchor%29%29) and [namespace-anchor->namespace](Namespaces.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._namespace-anchor-~3enamespace%29%29) wrap those to provide a clearer interface. A [variable reference](#%28tech._variable._reference%29) is also useful to low-level extensions; see [Inside: Racket C API](https://plt.cs.northwestern.edu/new-snapshots/new-snapshots/doc/local-redirect/index.html?doc=inside&rel=index.html&version=8.18.0.13).

Changed in version 8.2.0.7 of package base: Changed [#%top](__top.html#%28form._%28%28quote._~23~25kernel%29._~23~25top%29%29) treatment to be consistent with [#%top](__top.html#%28form._%28%28quote._~23~25kernel%29._~23~25top%29%29) by itself.

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

# 3.7 Procedure Applications and #%app

### 3.7 Procedure Applications and [#%app](#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._~23~25app%29%29)

> > > [Function Calls](https://plt.cs.northwestern.edu/new-snapshots/new-snapshots/doc/local-redirect/index.html?doc=guide&rel=application.html&version=8.18.0.13) in [The Racket Guide](https://plt.cs.northwestern.edu/new-snapshots/new-snapshots/doc/local-redirect/index.html?doc=guide&rel=index.html&version=8.18.0.13) introduces procedure applications.

> ```
syntax

(proc-expr arg ...)
```


### 2.5 Notation for Parameter Documentation
(parameter)	→```
Combines [letrec-syntaxes](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._letrec-syntaxes%29%29) with a variant of [letrec-values](#%28form._%28%28quote._~23~25kernel%29._letrec-values%29%29): each trans-id and val-id is bound in all trans-exprs and val-exprs.
The [letrec-syntaxes+values](#%28form._%28%28quote._~23~25kernel%29._letrec-syntaxes%2Bvalues%29%29) form is the core form for local compile-time bindings, since forms like [letrec-syntax](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._letrec-syntax%29%29) and [internal-definition contexts](syntax-model.html#%28tech._internal._definition._context%29) expand to it. In a fully expanded expression (see [Fully Expanded Programs](syntax-model.html#%28part._fully-expanded%29)), the trans-id bindings are discarded and the form reduces to a combination of [letrec-values](#%28form._%28%28quote._~23~25kernel%29._letrec-values%29%29) or [let-values](#%28form._%28%28quote._~23~25kernel%29._let-values%29%29).


### 2.5 Notation for Parameter Documentation
For variables bound by [letrec-syntaxes+values](#%28form._%28%28quote._~23~25kernel%29._letrec-syntaxes%2Bvalues%29%29), the [location](eval-model.html#%28tech._location%29)-creation rules differ slightly from [letrec-values](#%28form._%28%28quote._~23~25kernel%29._letrec-values%29%29). The \[(val-id [...](stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29)) val-expr\] binding clauses are partitioned into minimal sets of clauses that satisfy the following rule: if a clause has a val-id binding that is referenced (in a full expansion) by the val-expr of an earlier clause, the two clauses and all in between are in the same set. If a set consists of a single clause whose val-expr does not refer to any of the clause’s val-ids, then [locations](eval-model.html#%28tech._location%29) for the val-ids are created after the val-expr is evaluated. Otherwise, [locations](eval-model.html#%28tech._location%29) for all val-ids in a set are created just before the first val-expr in the set is evaluated. For the purposes of forming sets, a ([quote-syntax](Syntax_Quoting__quote-syntax.html#%28form._%28%28quote._~23~25kernel%29._quote-syntax%29%29) datum #:local) form counts as a reference to all bindings in the [letrec-syntaxes+values](#%28form._%28%28quote._~23~25kernel%29._letrec-syntaxes%2Bvalues%29%29) form


### 2.5 Notation for Parameter Documentation
The end result of the [location](eval-model.html#%28tech._location%29)-creation rules is that scoping and evaluation order are the same as for [letrec-values](#%28form._%28%28quote._~23~25kernel%29._letrec-values%29%29), but the compiler has more freedom to optimize away [location](eval-model.html#%28tech._location%29) creation. The rules also correspond to a nesting of [let-values](#%28form._%28%28quote._~23~25kernel%29._let-values%29%29) and [letrec-values](#%28form._%28%28quote._~23~25kernel%29._letrec-values%29%29), which is how [letrec-syntaxes+values](#%28form._%28%28quote._~23~25kernel%29._letrec-syntaxes%2Bvalues%29%29) for a fully-expanded expression.
See also [local](local.html#%28form._%28%28lib._racket%2Flocal..rkt%29._local%29%29), which supports local bindings with [define](define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29), [define-syntax](define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define-syntax%29%29), and more.
------------------------------------------------------------------------


# 3.10 Local Definitions: local


### 3.10 Local Definitions: [local](#%28form._%28%28lib._racket%2Flocal..rkt%29._local%29%29)
|                                                                                |                                                                                |
|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------:|
|  ([require](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) [racket/local]()) |  package: [base](https://pkgs.racket-lang.org/package/base "Install this package using `raco pkg install base`") |
The bindings documented in this section are provided by the [racket/local]() and [racket](index.html) libraries, but not [racket/base](index.html).
>
<colgroup><col style="width: 100%" /></colgroup>

syntax

([local](#%28form._%28%28lib._racket%2Flocal..rkt%29._local%29%29) [definition ...] body ...+)


### 3.10 Local Definitions: [local](#%28form._%28%28lib._racket%2Flocal..rkt%29._local%29%29)
Like [letrec-syntaxes+values](let.html#%28form._%28%28quote._~23~25kernel%29._letrec-syntaxes%2Bvalues%29%29), except that the bindings are expressed in the same way as in the top-level or in a module body: using [define](define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29), [define-values](define.html#%28form._%28%28quote._~23~25kernel%29._define-values%29%29), [define-syntax](define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define-syntax%29%29), [struct](define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29), etc. Definitions are distinguished from non-definitions by partially expanding definition forms (see [Partial Expansion](syntax-model.html#%28part._partial-expansion%29)). As in the top-level or in a module body, a [begin](begin.html#%28form._%28%28quote._~23~25kernel%29._begin%29%29)-wrapped sequence is spliced into the sequence of definitions.
------------------------------------------------------------------------


# 3.11 Constructing Graphs: shared


### 3.11 Constructing Graphs: [shared](#%28form._%28%28lib._racket%2Fshared..rkt%29._shared%29%29)
|                                                                                |                                                                                |
|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------:|
|  ([require](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) [racket/shared]()) |  package: [base](https://pkgs.racket-lang.org/package/base "Install this package using `raco pkg install base`") |
The bindings documented in this section are provided by the [racket/shared]() and [racket](index.html) libraries, but not [racket/base](index.html).
>
<colgroup><col style="width: 100%" /></colgroup>

syntax

([shared](#%28form._%28%28lib._racket%2Fshared..rkt%29._shared%29%29) ([id expr] ...) body ...+)

Binds ids with shared structure according to exprs and then evaluates the bodys, returning the result of the last expression.


### 3.11 Constructing Graphs: [shared](#%28form._%28%28lib._racket%2Fshared..rkt%29._shared%29%29)
The [shared](#%28form._%28%28lib._racket%2Fshared..rkt%29._shared%29%29) form is similar to [letrec](let.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._letrec%29%29), except that special forms of expr are recognized (after partial macro expansion) to construct graph-structured data, where the corresponding [letrec](let.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._letrec%29%29) would instead produce a use-before-initialization error.
Each expr (after partial expansion) is matched against the following shared-expr grammar, where earlier variants in a production take precedence over later variants:


### 3.11 Constructing Graphs: [shared](#%28form._%28%28lib._racket%2Fshared..rkt%29._shared%29%29)
|                     |     |     |     |                                                                                |
|--------------------:|:----|:---:|:----|:----------------------------------------------------------------------------------------------------------------------------------------------------|
|         shared-expr |     |  =  |     | shell-expr                                                                                |
|                     |     | \|  |     | plain-expr                                                                                |
|                     |     |     |     |                                                                                |
|          shell-expr |     |  =  |     | ([cons](pairs.html#%28def._%28%28quote._~23~25kernel%29._cons%29%29) in-immutable-expr in-immutable-expr)             |
|                     |     | \|  |     | ([list](pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29) in-immutable-expr ...)                           |
|                     |     | \|  |     | ([list*](pairs.html#%28def._%28%28quote._~23~25kernel%29._list%2A%29%29) in-immutable-expr ...)                       |
|                     |     | \|  |     | ([append](pairs.html#%28def._%28%28quote._~23~25kernel%29._append%29%29) early-expr ... in-immutable-expr)            |
|                     |     | \|  |     | ([vector-immutable](vectors.html#%28def._%28%28quote._~23~25kernel%29._vector-immutable%29%29) in-immutable-expr ...) |
|                     |     | \|  |     | ([box-immutable](boxes.html#%28def._%28%28quote._~23~25kernel%29._box-immutable%29%29) in-immutable-expr)             |
|                     |     | \|  |     | ([mcons](mpairs.html#%28def._%28%28quote._~23~25kernel%29._mcons%29%29) patchable-expr patchable-expr)                |
|                     |     | \|  |     | ([vector](vectors.html#%28def._%28%28quote._~23~25kernel%29._vector%29%29) patchable-expr ...)                        |
|                     |     | \|  |     | ([box](boxes.html#%28def._%28%28quote._~23~25kernel%29._box%29%29) patchable-expr)                                    |
|                     |     | \|  |     | (prefix:make-id patchable-expr ...)                                                                                |
|                     |     |     |     |                                                                                |
|   in-immutable-expr |     |  =  |     | shell-id                                                                                |
|                     |     | \|  |     | shell-expr                                                                                |
|                     |     | \|  |     | early-expr                                                                                |
|                     |     |     |     |                                                                                |
|            shell-id |     |  =  |     | id                                                                                |
|                     |     |     |     |                                                                                |
|      patchable-expr |     |  =  |     | expr                                                                                |
|                     |     |     |     |                                                                                |
|          early-expr |     |  =  |     | expr                                                                                |
|                     |     |     |     |                                                                                |
|          plain-expr |     |  =  |     | expr                                                                                |


### 3.11 Constructing Graphs: [shared](#%28form._%28%28lib._racket%2Fshared..rkt%29._shared%29%29)
The prefix:make-id identifier above matches three kinds of references. The first kind is any binding whose name has make- in the middle, and where prefix:id has a [transformer](syntax-model.html#%28tech._transformer%29) binding to structure information with a full set of mutator bindings; see [Structure Type Transformer Binding](structinfo.html). The second kind is an identifier that itself has a [transformer](syntax-model.html#%28tech._transformer%29) binding to structure information. The third kind is an identifier that has a 'constructor-for [syntax property](stxprops.html#%28tech._syntax._property%29) whose value is an identifier with a [transformer](syntax-model.html#%28tech._transformer%29) binding to structure information. A shell-id, meanwhile, must be one of the ids bound by the [shared](#%28form._%28%28lib._racket%2Fshared..rkt%29._shared%29%29) form to a shell-expr.


### 3.11 Constructing Graphs: [shared](#%28form._%28%28lib._racket%2Fshared..rkt%29._shared%29%29)
When the exprs of the [shared](#%28form._%28%28lib._racket%2Fshared..rkt%29._shared%29%29) form are parsed as shared-expr (taking into account the order of the variants for parsing precedence), the sub-expressions that were parsed via early-expr will be evaluated first when the [shared](#%28form._%28%28lib._racket%2Fshared..rkt%29._shared%29%29) form is evaluated. Among such expressions, they are evaluated in the order as they appear within the [shared](#%28form._%28%28lib._racket%2Fshared..rkt%29._shared%29%29) form. However, any reference to an id bound by [shared](#%28form._%28%28lib._racket%2Fshared..rkt%29._shared%29%29) produces a use-before-initialization errror, even if the binding for the id appears before the corresponding early-expr within the [shared](#%28form._%28%28lib._racket%2Fshared..rkt%29._shared%29%29) form.
The shell-ids and shell-exprs (not counting patchable-expr and early-expr sub-expressions) are effectively evaluated next:
-   A shell-id reference produces the same value as the corresponding id will produce within the bodys, assuming that id is never mutated with [set!](set_.html#%28form._%28%28quote._~23~25kernel%29._set%21%29%29). This special handling of a shell-id reference is one way in which [shared](#%28form._%28%28lib._racket%2Fshared..rkt%29._shared%29%29) supports the creation of cyclic data, including immutable cyclic data.


### 3.11 Constructing Graphs: [shared](#%28form._%28%28lib._racket%2Fshared..rkt%29._shared%29%29)
-   A shell-expr of the form ([mcons](mpairs.html#%28def._%28%28quote._~23~25kernel%29._mcons%29%29) patchable-expr patchable-expr), ([vector](vectors.html#%28def._%28%28quote._~23~25kernel%29._vector%29%29) patchable-expr [...](stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29)), ([box](boxes.html#%28def._%28%28quote._~23~25kernel%29._box%29%29) patchable-expr), or (prefix:make-id patchable-expr [...](stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29)) produces a mutable value whose content positions are initialized to [undefined](undefined.html#%28def._%28%28lib._racket%2Fundefined..rkt%29._undefined%29%29). Each content position is patched (i.e., updated) after the corresponding patchable-expr expression is later evaluated.
Next, the plain-exprs are evaluated as for [letrec](let.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._letrec%29%29), where a reference to an id raises [exn:fail:contract:variable](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3acontract~3avariable%29%29) if it is evaluated before the right-hand side of the id binding.


### 3.11 Constructing Graphs: [shared](#%28form._%28%28lib._racket%2Fshared..rkt%29._shared%29%29)
Finally, the patchable-exprs are evaluated and their values replace [undefined](undefined.html#%28def._%28%28lib._racket%2Fundefined..rkt%29._undefined%29%29)s in the results of shell-exprs. At this point, all ids are bound, so patchable-exprs can create data cycles (but only with cycles that can be created via mutation).
Examples:
> ```racket
> > ( shared ( [ a ( cons 1 a ) ] ) a )
> #0='(1 . #0#)
> > ( shared ( [ a ( cons 1 b ) ] [ b ( cons 2 a ) ] ) a )
> #0='(1 2 . #0#)
> > ( shared ( [ a ( cons 1 b ) ] [ b 7 ] ) a )
> '(1 . 7)
> > ( shared ( [ a a ] ) ; no indirection... a )
> a: undefined;
> cannot use before initialization
> > ( shared ( [ a ( cons 1 b ) ] ; b is early... [ b a ] ) a )
> a: undefined;
> cannot use before initialization
> > ( shared ( [ a ( mcons 1 b ) ] ; b is patchable... [ b a ] ) a )
> #0=(mcons 1 #0#)
> > ( shared ( [ a ( vector b b b ) ] [ b ( box 1 ) ] ) ( set-box! b 5 ) a )
> '#(#&5 #&5 #&5)
> > ( shared ( [ a ( box b ) ] [ b ( vector ( unbox a ) ; unbox after a is patched ( unbox c ) ) ] ; unbox before c is patched [ c ( box b ) ] ) b )
> #0='#(#0# #<undefined>)
> ```
------------------------------------------------------------------------


# 3.12 Conditionals: if, cond, and, and or


### 3.12 Conditionals: [if](#%28form._%28%28quote._~23~25kernel%29._if%29%29), [cond](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._cond%29%29), [and](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._and%29%29), and [or](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._or%29%29)
> > > [Conditionals](https://plt.cs.northwestern.edu/new-snapshots/new-snapshots/doc/local-redirect/index.html?doc=guide&rel=conditionals.html&version=8.18.0.13) in [The Racket Guide](https://plt.cs.northwestern.edu/new-snapshots/new-snapshots/doc/local-redirect/index.html?doc=guide&rel=index.html&version=8.18.0.13) introduces conditionals.
>
<colgroup><col style="width: 100%" /></colgroup>

syntax

([if](#%28form._%28%28quote._~23~25kernel%29._if%29%29) test-expr then-expr else-expr)

Evaluates test-expr. If it produces any value other than #f, then then-expr is evaluated, and its results are the result for the [if](#%28form._%28%28quote._~23~25kernel%29._if%29%29) form. Otherwise, else-expr is evaluated, and its results are the result for the [if](#%28form._%28%28quote._~23~25kernel%29._if%29%29) form. The then-expr and else-expr are in tail position with respect to the [if](#%28form._%28%28quote._~23~25kernel%29._if%29%29) form.
Examples:


### 3.12 Conditionals: [if](#%28form._%28%28quote._~23~25kernel%29._if%29%29), [cond](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._cond%29%29), [and](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._and%29%29), and [or](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._or%29%29)
> ```racket
> > ( if ( positive? -5 ) ( error "doesn't get here" ) 2 )
> 2
> > ( if ( positive? 5 ) 1 ( error "doesn't get here" ) )
> 1
> > ( if ' we-have-no-bananas "yes" "no" )
> "yes"
> ```
>
<colgroup><col style="width: 100%" /></colgroup>

syntax


### 3.12 Conditionals: [if](#%28form._%28%28quote._~23~25kernel%29._if%29%29), [cond](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._cond%29%29), [and](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._and%29%29), and [or](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._or%29%29)

([cond](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._cond%29%29) cond-clause ...)

cond-clause	 	=	 	[test-expr then-body ...+]

 	 	|	 	[[else](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._else%29%29) then-body ...+]

 	 	|	 	[test-expr [=>](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._~3d~3e%29%29) proc-expr]

 	 	|	 	[test-expr]


### 3.12 Conditionals: [if](#%28form._%28%28quote._~23~25kernel%29._if%29%29), [cond](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._cond%29%29), [and](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._and%29%29), and [or](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._or%29%29)
> > > <img src="finger.png" width="24" height="24" alt="+" />[Chaining Tests: cond](https://plt.cs.northwestern.edu/new-snapshots/new-snapshots/doc/local-redirect/index.html?doc=guide&rel=conditionals.html%23%2528part._cond%2529&version=8.18.0.13) in [The Racket Guide](https://plt.cs.northwestern.edu/new-snapshots/new-snapshots/doc/local-redirect/index.html?doc=guide&rel=index.html&version=8.18.0.13) introduces [cond](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._cond%29%29).
A cond-clause that starts with [else](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._else%29%29) must be the last cond-clause.
If no cond-clauses are present, 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).


### 3.12 Conditionals: [if](#%28form._%28%28quote._~23~25kernel%29._if%29%29), [cond](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._cond%29%29), [and](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._and%29%29), and [or](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._or%29%29)
If only a \[[else](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._else%29%29) then-body [...+](https://plt.cs.northwestern.edu/new-snapshots/new-snapshots/doc/local-redirect/index.html?doc=syntax&rel=stxparse-patterns.html%23%2528form._%2528%2528lib._syntax%252Fparse..rkt%2529._......%252B%2529%2529&version=8.18.0.13)\] is present, then the then-bodys are evaluated. The results from all but the last then-body are ignored. The results of the last then-body, which is in tail position with respect to the [cond](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._cond%29%29) form, are the results for the whole [cond](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._cond%29%29) form.
Otherwise, the first test-expr is evaluated. If it produces #f, then the result is the same as a [cond](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._cond%29%29) form with the remaining cond-clauses, in tail position with respect to the original [cond](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._cond%29%29) form. Otherwise, evaluation depends on the form of the cond-clause:


### 3.12 Conditionals: [if](#%28form._%28%28quote._~23~25kernel%29._if%29%29), [cond](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._cond%29%29), [and](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._and%29%29), and [or](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._or%29%29)
> > |                              |
> > |------------------------------|
> > | \[test-expr then-body ...+\] |
>
> The then-bodys are evaluated in order, and the results from all but the last then-body are ignored. The results of the last then-body, which is in tail position with respect to the [cond](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._cond%29%29) form, provides the result for the whole [cond](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._cond%29%29) form.


### 3.12 Conditionals: [if](#%28form._%28%28quote._~23~25kernel%29._if%29%29), [cond](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._cond%29%29), [and](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._and%29%29), and [or](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._or%29%29)
> > |                                                                                |
> > |--------------------------------------------------------------------------------------------------------------------------------------------|
> > | \[test-expr [=>](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._~3d~3e%29%29) proc-expr\] |
>
> The proc-expr is evaluated, and it must produce a procedure that accepts one argument, otherwise the [exn:fail:contract](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3acontract%29%29) exception is raised. The procedure is applied to the result of test-expr in tail position with respect to the [cond](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._cond%29%29) expression.
> > |               |
> > |---------------|
> > | \[test-expr\] |
>
> The result of the test-expr is returned as the result of the [cond](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._cond%29%29) form. The test-expr is not in tail position.
Examples:


### 3.12 Conditionals: [if](#%28form._%28%28quote._~23~25kernel%29._if%29%29), [cond](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._cond%29%29), [and](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._and%29%29), and [or](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._or%29%29)
> ```racket
> > ( cond )
> > ( cond [ else 5 ] )
> 5
> > ( cond [ ( positive? -5 ) ( error "doesn't get here" ) ] [ ( zero? -5 ) ( error "doesn't get here, either" ) ] [ ( positive? 5 ) ' here ] )
> 'here
> > ( cond [ ( member 2 ' ( 1 2 3 ) ) => ( lambda ( l ) ( map - l ) ) ] )
> '(-2 -3)
> > ( cond [ ( member 2 ' ( 1 2 3 ) ) ] )
> '(2 3)
> ```
>
<colgroup><col style="width: 100%" /></colgroup>

syntax

[else](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._else%29%29)

Recognized specially within forms like [cond](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._cond%29%29). An [else](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._else%29%29) form as an expression is a syntax error.
>
<colgroup><col style="width: 100%" /></colgroup>

syntax

[=>](#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._~3d~3e%29%29)