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

  1. Path: sparky!uunet!dtix!darwin.sura.net!wupost!cs.utexas.edu!asuvax!farallon!danny.farallon.com!user
  2. From: danny@farallon.com (Danny Brewer)
  3. Newsgroups: comp.lang.lisp
  4. Subject: Can I use EVAL?
  5. Message-ID: <danny-250892143222@danny.farallon.com>
  6. Date: 25 Aug 92 19:52:35 GMT
  7. Sender: news@farallon.farallon.com
  8. Followup-To: comp.lang.lisp
  9. Organization: Farallon Computing, Inc.
  10. Lines: 32
  11. Nntp-Posting-Host: danny
  12.  
  13. I have a compiling matcher I've written that takes a pattern and
  14. returns a LAMBDA expression which performs the actual match.
  15. Here is an example:  (MCL2 prompts with a "?")
  16.  
  17. ;;; Match a pattern and datum using the interpretive matcher
  18.  
  19. ? (Match '(a ?x c) '(a b c))
  20. ((?X . B))
  21.  
  22. ;;; It matches with one variable binding.
  23. ;;; Now compile the pattern into a LAMBDA using compiling matcher
  24.  
  25. ? (Compile-Match '(a ?x c))
  26. (LAMBDA (DATUM ...)  [...a bunch of code deleted...] )
  27.  
  28. ? (SETF *p* *)           ; save pattern code in a variable
  29. ? (SETF *d* '(a b c))    ; set datum variable
  30.  
  31. Now that I've got the LAMBDA in the variable *p*, how can I do
  32. anything with it?  I can't FUNCALL or APPLY it.  But I can
  33. use a really ugly EVAL as follows:
  34.  
  35. ? (EVAL `(,*p* ',*d*))
  36. ((?X . B))
  37.  
  38. This works okay, but yucko!
  39.  
  40. Anybody got any better ideas?
  41. Thanks.
  42.  
  43. Danny Brewer
  44. danny@farallon.com
  45.