DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

(r5rs.info.gz) Macros

Info Catalog (r5rs.info.gz) Derived expression types (r5rs.info.gz) Expressions
 
 4.3 Macros
 ==========
 

Menu

 
* Binding constructs for syntactic keywords
* Pattern language
 
 Scheme programs can define and use new derived expression types,
 called _macros_.  Program-defined expression types have the syntax
 
 
      (<keyword> <datum> ...)
 
 where <keyword> is an identifier that uniquely determines the
 expression type.  This identifier is called the _syntactic keyword_, or
 simply _keyword_, of the macro.  The number of the <datum>s, and their
 syntax, depends on the expression type.
 
 Each instance of a macro is called a _use_ of the macro.  The set of
 rules that specifies how a use of a macro is transcribed into a more
 primitive expression is called the _transformer_ of the macro.
 
 The macro definition facility consists of two parts:
 
    * A set of expressions used to establish that certain identifiers
      are macro keywords, associate them with macro transformers, and
      control the scope within which a macro is defined, and
 
    * a pattern language for specifying macro transformers.
 
 
 The syntactic keyword of a macro may shadow variable bindings, and local
 variable bindings may shadow keyword bindings.    All macros defined
 using the pattern language  are "hygienic" and "referentially
 transparent" and thus preserve Scheme's lexical scoping [Kohlbecker86],
 [ hygienic], [Bawden88], [macrosthatwork], [syntacticabstraction]:
 
    * If a macro transformer inserts a binding for an identifier
      (variable or keyword), the identifier will in effect be renamed
      throughout its scope to avoid conflicts with other identifiers.
      Note that a `define' at top level may or may not introduce a
      binding; see section  Definitions.
 
    * If a macro transformer inserts a free reference to an identifier,
      the reference refers to the binding that was visible where the
      transformer was specified, regardless of any local bindings that
      may surround the use of the macro.
 
 
Info Catalog (r5rs.info.gz) Derived expression types (r5rs.info.gz) Expressions
automatically generated byinfo2html