DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

(m4.info.gz) Indir

Info Catalog (m4.info.gz) Pushdef (m4.info.gz) Definitions (m4.info.gz) Builtin
 
 4.7 Indirect call of macros
 ===========================
 
 Any macro can be called indirectly with `indir':
 
  -- Builtin: indir (NAME, ...)
      Results in a call to the macro NAME, which is passed the rest of
      the arguments.  If NAME is not defined, an error message is
      printed, and the expansion is void.
 
      The macro `indir' is recognized only with parameters.
 
    This can be used to call macros with computed or "invalid" names
 (`define' allows such names to be defined):
 
      define(`$$internal$macro', `Internal macro (name `$0')')
      =>
      $$internal$macro
      =>$$internal$macro
      indir(`$$internal$macro')
      =>Internal macro (name $$internal$macro)
 
    The point is, here, that larger macro packages can have private
 macros defined, that will not be called by accident.  They can _only_ be
 called through the builtin `indir'.
 
    One other point to observe is that argument collection occurs before
 `indir' invokes NAME, so if argument collection changes the value of
 NAME, that will be reflected in the final expansion.  This is different
 than the behavior when invoking macros directly, where the definition
 that was in effect before argument collection is used.
 
      define(`f', `1')
      =>
      f(define(`f', `2'))
      =>1
      indir(`f', define(`f', `3'))
      =>3
      indir(`f', undefine(`f'))
      error-->m4:stdin:4: undefined macro `f'
      =>
 
Info Catalog (m4.info.gz) Pushdef (m4.info.gz) Definitions (m4.info.gz) Builtin
automatically generated byinfo2html