home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / lisp / 2307 < prev    next >
Encoding:
Internet Message Format  |  1992-08-26  |  1.5 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!Sirius.dfn.de!chx400!sicsun!disuns2!disuns2.epfl.ch!simon
  2. From: simon@lia.di.epfl.ch (Simon Leinen)
  3. Newsgroups: comp.lang.lisp
  4. Subject: Re: Can I use EVAL?
  5. Message-ID: <SIMON.92Aug27095229@liasg1.epfl.ch>
  6. Date: 27 Aug 92 07:52:29 GMT
  7. References: <danny-250892143222@danny.farallon.com>
  8. Sender: news@disuns2.epfl.ch
  9. Followup-To: comp.lang.lisp
  10. Organization: DI-LIA -- Ecole Polytechnique Federale de Lausanne
  11. Lines: 27
  12. Nntp-Posting-Host: liasg1.epfl.ch
  13. In-reply-to: danny@farallon.com's message of 25 Aug 92 19:52:35 GMT
  14. X-Md4-Signature: c000bb6de9cf55af90e8b58c6acb8db9
  15.  
  16. In article <danny-250892143222@danny.farallon.com> danny@farallon.com
  17. (Danny Brewer) writes:
  18.  
  19.    ? (Compile-Match '(a ?x c))
  20.    (LAMBDA (DATUM ...)  [...a bunch of code deleted...] )
  21.  
  22.    ? (SETF *p* *)           ; save pattern code in a variable
  23.    ? (SETF *d* '(a b c))    ; set datum variable
  24.  
  25.    Now that I've got the LAMBDA in the variable *p*, how can I do
  26.    anything with it?  I can't FUNCALL or APPLY it.
  27.  
  28. You can funcall the lambda expression by coercing it to FUNCTION first
  29. (this is only necessary in ANSIfied Common Lisps):
  30.  
  31.     (funcall (coerce *p* 'function) *d*)
  32.  
  33. ...but this is really very equivalent to using EVAL.
  34. Or you can force compilation of the code using COMPILE:
  35.  
  36.     (funcall (compile nil *p*) *d*)
  37.  
  38. In this case you would probably save the result of the COMPILE
  39. somewhere because compilation makes most sense when you reuse the
  40. compiled matcher for many operations.
  41. -- 
  42. Simon.
  43.