home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / lisp / mcl / 1606 < prev    next >
Encoding:
Text File  |  1992-11-17  |  2.2 KB  |  57 lines

  1. Path: sparky!uunet!mcsun!Germany.EU.net!sbsvax!coli-gate.coli.uni-sb.de!mp-mac10.coli.uni-sb.de!espen
  2. From: espen@coli.uni-sb.de (Espen J. Vestre)
  3. Newsgroups: comp.lang.lisp.mcl
  4. Subject: Re: Making a lambda-expr more like a fn
  5. Message-ID: <1992Nov17.133808.21811@coli.uni-sb.de>
  6. Date: 17 Nov 92 13:38:08 GMT
  7. References: <9211161528.AA16443@cambridge.apple.com>
  8. Sender: news@coli.uni-sb.de (Usenet news system)
  9. Organization: Computerlinguistik, Universitaet des Saarlandes
  10. Lines: 42
  11. X-Xxmessage-Id: <A72EB32F77034453@mp-mac10.coli.uni-sb.de>
  12. X-Useragent: Nuntius v1.1.1d12
  13. X-Xxdate: Tue, 17 Nov 92 13: 33:19 GMT
  14.  
  15. In article <9211161528.AA16443@cambridge.apple.com> Bill St. Clair,
  16. bill@cambridge.apple.com writes:
  17. >3) write (funcall 'coerce x 'function) instead of (coerce x 'function)
  18. >   This will be slightly slower than option 2, but I doubt you'll notice.
  19.  
  20. something which as far as I can see has been left unclear in this
  21. discussion, is the fact that the function returned by (funcall 'coerce x
  22. 'function) is _different_ from the one that x itself denotes.  For
  23. instance,
  24. (list
  25.  (progn
  26.    (setq x 'initial-x)
  27.    (list
  28.     (let ((x 'old-value))
  29.       ((lambda ()(setq x 'new-value)))
  30.       x)
  31.     x))
  32.  (progn
  33.    (setq x 'initial-x)
  34.    (list
  35.     (let ((x 'old-value))
  36.       (funcall (funcall 'coerce '(lambda ()(setq x 'new-value))
  37. 'function))
  38.       x)
  39.     x)))
  40. evaluates to ((new-value initial-x) (old-value new-value)).
  41. I.e., the effect of (coerce x 'function) is _not_ a function which does
  42. exactly what x would have done in the same lexical position, but rather
  43. the function given by (eval `(function ,x)), i.e. the function x denotes
  44. in a null lexical environment.
  45.  
  46. A much better idea, I think, is to consequently enclose
  47. lambda-expressions in #' where they are defined, and to include (declare
  48. (special...)) in the lambda expression for those variables which are to
  49. have dynamic scope.
  50. --------------------------------------------------------------
  51. Espen J. Vestre,                          espen@coli.uni-sb.de
  52. Universitaet des Saarlandes,        
  53. Computerlinguistik, Gebaeude 17.2 
  54. Im Stadtwald,                          tel. +49 (681) 302 4501
  55. D-6600 SAARBRUECKEN, Germany           fax. +49 (681) 302 4351
  56. --------------------------------------------------------------
  57.