DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

(m4.info.gz) Pushdef

Info Catalog (m4.info.gz) Defn (m4.info.gz) Definitions (m4.info.gz) Indir
 
 Temporarily redefining macros
 =============================
 
    It is possible to redefine a macro temporarily, reverting to the
 previous definition at a later time.  This is done with the builtins
 `pushdef' and `popdef':
 
      pushdef(NAME [, EXPANSION])
      popdef(NAME)
 
 which are quite analogous to `define' and `undefine'.
 
    These macros work in a stack-like fashion.  A macro is temporarily
 redefined with `pushdef', which replaces an existing definition of
 NAME, while saving the previous definition, before the new one is
 installed.  If there is no previous definition, `pushdef' behaves
 exactly like `define'.
 
    If a macro has several definitions (of which only one is accessible),
 the topmost definition can be removed with `popdef'.  If there is no
 previous definition, `popdef' behaves like `undefine'.
 
      define(`foo', `Expansion one.')
      =>
      foo
      =>Expansion one.
      pushdef(`foo', `Expansion two.')
      =>
      foo
      =>Expansion two.
      popdef(`foo')
      =>
      foo
      =>Expansion one.
      popdef(`foo')
      =>
      foo
      =>foo
 
    If a macro with several definitions is redefined with `define', the
 topmost definition is *replaced* with the new definition.  If it is
 removed with `undefine', *all* the definitions are removed, and not
 only the topmost one.
 
      define(`foo', `Expansion one.')
      =>
      foo
      =>Expansion one.
      pushdef(`foo', `Expansion two.')
      =>
      foo
      =>Expansion two.
      define(`foo', `Second expansion two.')
      =>
      foo
      =>Second expansion two.
      undefine(`foo')
      =>
      foo
      =>foo
 
    It is possible to temporarily redefine a builtin with `pushdef' and
 `defn'.
 
    The macros `pushdef' and `popdef' are recognized only with
 parameters.
 
Info Catalog (m4.info.gz) Defn (m4.info.gz) Definitions (m4.info.gz) Indir
automatically generated byinfo2html