[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: issue DEFINING-MACROS-NON-TOP-LEVEL, version 6
- To: Jeff Dalton <jeff%aiai.edinburgh.ac.uk@NSS.Cs.Ucl.AC.UK>
- Subject: Re: issue DEFINING-MACROS-NON-TOP-LEVEL, version 6
- From: sandra%defun@cs.utah.edu (Sandra J Loosemore)
- Date: Wed, 4 Jan 89 08:59:53 MST
- Cc: sandra <sandra%defun@cs.utah.edu>, cl-compiler@sail.stanford.edu
- In-reply-to: Jeff Dalton <jeff%aiai.edinburgh.ac.uk@NSS.Cs.Ucl.AC.UK>, Tue, 3 Jan 89 17:06:28 GMT
Suppose I have the example from CLtL:
(let ((old-count *access-count*))
(unwind-protect
(progn
(incf *access-count*)
(perform-access))
(setq *access-count* old-count)))
This is entirely equivalent to:
(let ((old-count *access-count*))
(let ((thunk #'(lambda () (setq *access-count* old-count))))
(unwind-protect
(progn
(incf *access-count*)
(perform-access))
(funcall thunk))))
This is a real example from the A-Lisp compiler. A-Lisp implements
UNWIND-PROTECT by pushing a "thunk" (a function of no arguments) which
performs the cleanup actions onto the catch stack, before executing
the protected form. Since the compiler has to generate code to fiddle
with the "thunk" before it emits the code for the protected form, it
seems perfectly reasonable for it to rearrange the source code. A-Lisp
does in fact use a source-to-source transformation in the first phase of
the compiler to do this.
-Sandra
-------