home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / usr.bin / lisp / lispnews / text0150.txt < prev    next >
Encoding:
Text File  |  1985-11-10  |  836 b   |  27 lines

  1.  The compiler will now compile the form
  2.        (*no-macroexpand* <form>)
  3.  in a special way: if <form> is a function call, e.g. (name arg1 ...),
  4.  then any macro properties of 'name' will be ignored for this
  5.  invocation.  This permits one to write macros which attempt
  6.  an optimization, and if that fails, then call the standard
  7.  function.  *no-macroexpand* is not a function that can be called,
  8.  thus forms with *no-macroexpand* are likely to be 'cmacros'.
  9.  Here is an example:
  10.  
  11.    (defcmacro length (x &protect (x))
  12.        `(if (null ,x)
  13.           then 0
  14.      elseif (null (cdr ,x))
  15.       then 1
  16.      else (*no-macroexpand* (length ,x))))
  17.  
  18.  
  19.  [in case you are wondering, the `&protect (x)' means that
  20.   should the actual argument to 'length' be a non atom, defcmacro
  21.   will lambda bind the value, insuring that it is only evaluated
  22.   once]
  23.  
  24.  
  25.  
  26.  
  27.