I hearby DECLARE, DECLAIM and PROCLAIM that I'm not quite sure I understand the difference between these three!
Well -- DECLARE is the easy one -- it has a block limited scope, while the other two have wider more global scope.
PROCLAIM is clearly global.
The distinction for DECLAIM seems a bit fuzzy to me. Is this because it's meant for the compiler and it really means: "it depends on how your compiler wants to handle it" ?
( Or an I just having trouble reading standardeese today? )
---| Steven D. Majewski (804-982-0831) <sd...@Virginia.EDU> |--- ---| Department of Molecular Physiology and Biological Physics |--- ---| University of Virginia Health Sciences Center |--- ---| P.O. Box 10011 Charlottesville, VA 22906-0011 |--- "Nature and Nature's laws lay hid in night: God said, let Newton be! and all was light." - pope
In article <6eu6uf$b4...@murdoch.acc.Virginia.EDU>, Steven D. Majewski <sd...@elvis.med.Virginia.EDU> wrote:
>Well -- DECLARE is the easy one -- it has a block limited scope, >while the other two have wider more global scope.
>PROCLAIM is clearly global.
>The distinction for DECLAIM seems a bit fuzzy to me. >Is this because it's meant for the compiler and it really >means: "it depends on how your compiler wants to handle it" ?
PROCLAIM is a function, while DECLAIM is a macro. So you can use PROCLAIM with declarations that you calculate, but it's pretty rare that you need to do this unless you're also calling COMPILE or COMPILE-FILE. DECLAIM doesn't evaluate its arguments, and expands into a PROCLAIM with an appropriate EVAL-WHEN wrapped around it so that it will do the right thing when the file is compiled.
One way to think of it is that DECLAIM is to PROCLAIM as DEFUN is to SETF of SYMBOL-FUNCTION. At the time Guy Steele came up with it, most of us didn't even know that the word "declaim" existed; we just wanted a DEFsomething macro, but DEsomething was close enough, and it was great that it really is a synonym for "proclaim"!
-- Barry Margolin, bar...@bbnplanet.com GTE Internetworking, Powered by BBN, Cambridge, MA *** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
the only thing I would wish for is that DECLAIM had no effect when loading. loading a file with DECLAIM often introduces declarations that are not wanted at load-time, like OPTIMIZE settings.
the consequence of this is that one has to wrap the proclamation in (EVAL-WHEN (:COMPILE-TOPLEVEL) ...) and this sort of defeats the purpose of having DECLAIM in the first place, IMHO. an obvious counter-measure is to include OPTIMIZE settings in every file that is to be compiled.
I wonder how the global declarations were intended to be used.
#:Erik -- religious cult update in light of new scientific discoveries: "when we cannot go to the comet, the comet must come to us."
I'm not so sure this is a correct rewrite. DECLAIM is specifically intended to work harder than this to cooperate with the compile-time environment so that its side-effect does not pervade into the global environment in which the compilation is occurring. DECLAIM is permitted to fall back to the above in the worst case, but the hope is that it will do better.
> the only thing I would wish for is that DECLAIM had no effect when > loading. loading a file with DECLAIM often introduces declarations that > are not wanted at load-time, like OPTIMIZE settings.
only if you're using DECLAIM wrong. DECLAIM's job is this:
(1) at compile time, make the side-effect available to the compilation unit. (2) at load time, make the side-effect available to the world.
the idea is that you should be able to implement DEFVAR as a DECLAIM+SETQ. once you've LOAD'd the DEFVAR, all code in any future situation should know it's a special, so it MUST proclaim upon load--doing less would not implement the guaranteed effect.
the idea however is that if you only compile a file containing such a DECLAIM, but do not load it, the effect of the compilation should not (if possible) affect your global environment. only some implementations really do this.
mostly i don't write code that depends on DECLAIM to do any different than PROCLAIM. But this was critically important on Lisp Machines, where people stay logged in for months at a time and want to be able to compile code they do not always want to load. In Symbolics Genera, therefore, compiling a file with (DECLAIM (SPECIAL ...)) won't force the symbols to be special after the compilation is done until/unless you also LOAD the file.
> the consequence of this is that one has to wrap the proclamation in > (EVAL-WHEN (:COMPILE-TOPLEVEL) ...) and this sort of defeats the purpose > of having DECLAIM in the first place, IMHO. an obvious counter-measure > is to include OPTIMIZE settings in every file that is to be compiled.
or in none of them. (personally, i only use optimize in a DECLARE or when I have arranged for the end of the file to reset normal optimize parameters for the system i'm building.) I agree it's more problematic, but I don't think that's declaim's fault. If you make it local to a file, people complain they can't have a single modular file that sets up optimize settings. If you make it not local, people complain they have to guard against files that don't clean up the mess they make. There is no uniquely agreed-upon win here at all for optimize, so it can't drive declaim's default behavior.
> I wonder how the global declarations were intended to be used.
I hope the above remarks help. All in all, though, the whole notion of global is a bit of a mess. We shoved in WITH-COMPILATION-UNIT somewhat hastily to address delayed warnings. I think more things should connect to it. I said "compilation unit" above but probably lied--wishful thinking--it's probably "file" for DECLAIM. I just wish it was compilation unit just because i'd like the bounding region of a compilation to be uniformly shared for all modules.