[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
type declarations of special bindings
- To: gz@spt.entity.com
- Subject: type declarations of special bindings
- From: Jon L White <edsel!jonl@labrea.Stanford.EDU>
- Date: Sat, 23 Jan 88 01:18:23 PST
- Cc: labrea!common-lisp%sail@labrea.Stanford.EDU
- In-reply-to: Gail Zacharias's message of 22 Jan 88 18:12:35 EST (Fri) <8801221812.AA05095@spt.entity.com>
re: In the following example, does the fixnum declaration apply to the
inner reference to X (in the setq)?
(let ((X 17))
(declare (special X) (fixnum X))
(let ((X 'local))
(locally
(declare (special X))
(setq X (foo)))))
CLtL, p 158 says that type declarations affect the binding "and specifies
that the variable[s] mentioned will take on values only of the specified
type". The inner reference is to the variable bound specially, not to
the one bound locally, so it is the same variable whose binding was
declared fixnum. Hence, in theory, it should be as if the form
(setq X (foo))
were written as
(setq X (the fixnum (foo)))
but I suspect very few, if any, compilers actually make this leap of type
inferencing.
-- JonL --