home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!Germany.EU.net!sbsvax!coli-gate.coli.uni-sb.de!mp-mac10.coli.uni-sb.de!espen
- From: espen@coli.uni-sb.de (Espen J. Vestre)
- Newsgroups: comp.lang.lisp.mcl
- Subject: Re: Making a lambda-expr more like a fn
- Message-ID: <1992Nov17.133808.21811@coli.uni-sb.de>
- Date: 17 Nov 92 13:38:08 GMT
- References: <9211161528.AA16443@cambridge.apple.com>
- Sender: news@coli.uni-sb.de (Usenet news system)
- Organization: Computerlinguistik, Universitaet des Saarlandes
- Lines: 42
- X-Xxmessage-Id: <A72EB32F77034453@mp-mac10.coli.uni-sb.de>
- X-Useragent: Nuntius v1.1.1d12
- X-Xxdate: Tue, 17 Nov 92 13: 33:19 GMT
-
- In article <9211161528.AA16443@cambridge.apple.com> Bill St. Clair,
- bill@cambridge.apple.com writes:
- >3) write (funcall 'coerce x 'function) instead of (coerce x 'function)
- > This will be slightly slower than option 2, but I doubt you'll notice.
-
- something which as far as I can see has been left unclear in this
- discussion, is the fact that the function returned by (funcall 'coerce x
- 'function) is _different_ from the one that x itself denotes. For
- instance,
- (list
- (progn
- (setq x 'initial-x)
- (list
- (let ((x 'old-value))
- ((lambda ()(setq x 'new-value)))
- x)
- x))
- (progn
- (setq x 'initial-x)
- (list
- (let ((x 'old-value))
- (funcall (funcall 'coerce '(lambda ()(setq x 'new-value))
- 'function))
- x)
- x)))
- evaluates to ((new-value initial-x) (old-value new-value)).
- I.e., the effect of (coerce x 'function) is _not_ a function which does
- exactly what x would have done in the same lexical position, but rather
- the function given by (eval `(function ,x)), i.e. the function x denotes
- in a null lexical environment.
-
- A much better idea, I think, is to consequently enclose
- lambda-expressions in #' where they are defined, and to include (declare
- (special...)) in the lambda expression for those variables which are to
- have dynamic scope.
- --------------------------------------------------------------
- Espen J. Vestre, espen@coli.uni-sb.de
- Universitaet des Saarlandes,
- Computerlinguistik, Gebaeude 17.2
- Im Stadtwald, tel. +49 (681) 302 4501
- D-6600 SAARBRUECKEN, Germany fax. +49 (681) 302 4351
- --------------------------------------------------------------
-