Path: utzoo!attcan!uunet!husc6!bloom-beacon!tut.cis.ohio-state.edu!mailrus!ames!necntc!primerd!zaphod!doug From: doug@zaphod.prime.com Newsgroups: comp.lang.lisp Subject: Re: SETQ vs DEFVAR at the top level Message-ID: <26500003@zaphod> Date: 1 Jul 88 14:31:00 GMT References: <4431@medusa.cs.purdue.edu> Lines: 33 Nf-ID: #R:medusa.cs.purdue.edu:-443100:zaphod:26500003:000:1380 Nf-From: zaphod.prime.com!doug Jul 1 10:31:00 1988 I think the difference between SETQ and DEFVAR in this instance is easy to explain. A SETQ at top level will refer to a global, hence dynamically scoped variable. A SETQ does not make any declarations about the referenced variable. A DEFVAR form is not equivalent to a SETQ. It differs in one unimportant and one very important way: 1) Unimportant, it only will give a value to an already unbound variable 2) Important, it does the equivalent to (PROCLAIM '(SPECIAL variable)) That second thing is what has screwed you up. The proclaimation is global. It overrides the normal behavior everywhere you use the symbol. So not only does your binding of *Q* in the let become dynamic but any use of *Q* as a parameter would become dynamic. Lest you think that I'm just rationalizing the following passage from CLtL relates to LET bindings (and therefore do DEFUN, LAMBDA, etc.): ... each binding will be a lexical binding unless there is a special declaration to the contrary... PROCLAIM has global extent and effects all such declarations. -------------------- Douglas Rand Internet: doug@zaphod.prime.com Usenet: primerd!zaphod!doug Phone: (508) - 879 - 2960 Mail: Prime Computer, 500 Old Conn Path, MS10C-17, Framingham, Ma 01701 -> The above opinions are mine alone and are not influenced by my employer, my cat or the clothes I wear.