home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / lisp / 2919 < prev    next >
Encoding:
Text File  |  1992-11-19  |  1.3 KB  |  35 lines

  1. Path: sparky!uunet!think.com!barmar
  2. From: barmar@think.com (Barry Margolin)
  3. Newsgroups: comp.lang.lisp
  4. Subject: Re: Help: apply for macros ???
  5. Date: 19 Nov 1992 21:17:51 GMT
  6. Organization: Thinking Machines Corporation, Cambridge MA, USA
  7. Lines: 23
  8. Message-ID: <1eh09vINNkc7@early-bird.think.com>
  9. References: <2610@bigfoot.first.gmd.de>
  10. NNTP-Posting-Host: telecaster.think.com
  11.  
  12. In article <2610@bigfoot.first.gmd.de> wolf@prosun.first.gmd.de (Wolfgang Koehler) writes:
  13. >Does there exist a similiar solution if "f" is a macro ???
  14.  
  15. Since macros are source-to-source transformations, this generally doesn't
  16. make sense to do.  If you wrote a function as a macro simply to speed it
  17. up, you should use an inline function rather than a macro.
  18.  
  19. But if you really want to do it, you could write something kludgey like:
  20.  
  21. (defun g (&rest args)
  22.   (eval `(f ,@args)))
  23.  
  24. Note that if the macro expansion results in any of its arguments being
  25. evaluted, they'll be evaluated twice: once as part of the call to G and
  26. later when the macroexpansion of F is executed.
  27.  
  28. Note: I'm *not* advocating this code, I think it's gross.  But if you have
  29. a macro without a functional counterpart, you sometimes need to do it.
  30. -- 
  31. Barry Margolin
  32. System Manager, Thinking Machines Corp.
  33.  
  34. barmar@think.com          {uunet,harvard}!think!barmar
  35.