Version: 5.2
8 Definitions
Provides macros for creating and manipulating definitions.
8.1 Deferred Evaluation in Modules
When used at the top level of a module, evaluates expr at the end of
the module. This can be useful for calling functions before their definitions.
Examples: |
| > (require 'Failure) | reference to an identifier before its definition: f in | module: 'Failure | | > (require 'Success) |
|
8.2 Conditional Binding
These are useful for writing programs that are portable across versions of
Racket with different bindings, to provide an implementation of a binding for
versions that do not have it but use the built-in one in versions that do.
8.3 Renaming Definitions
Establishes a
rename transformer
for each
new identifier, redirecting it to the corresponding
old identifier.
8.4 Forward Declarations
Provides forward declarations of identifiers to be defined later. It
is useful for macros which expand to mutually recursive definitions, including
forward references, that may be used at the Racket top level.
8.5 Definition Shorthands
Defines the form
name as a shorthand for setting the parameter
parameter. Specifically,
(name value body ...) is equivalent
to
(parameterize ([parameter value]) body ...).
8.6 Macro Definitions
Defines a syntax transformer for each
macro-id based on the local
definition of each
expander-id
(defaulting to
macro-id/proc) in
body ....
Especially useful for mutually recursive expander functions and phase 1 macro
definitions. Subsumes the behavior of
define-syntax-set.
Examples: |
| > (implies #t (printf "True!\n")) | True! | > (implies #f (printf "False!\n")) | #t | > (nand #t #t (printf "All True!\n")) | All True! | #f | > (nand #t #f (printf "Some False!\n")) | #t | | reference to undefined identifier: undefined-macro/proc |
|
8.7 Effectful Transformation
Executes e during phase 1 (the syntax transformation phase)
relative to its context, during pass 1 if it occurs in a head expansion
position.
Executes e during phase 1 (the syntax transformation phase)
relative to its context, during pass 2 (after head expansion).