Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

declaim? proclaim?

23 views
Skip to first unread message

Nils Goesche

unread,
Feb 16, 2002, 11:23:58 PM2/16/02
to
Hi!

I always find myself think very hard about when to use proclaim or
declaim. Obviously there is something I don't understand about
this. Could somebody be so kind as providing me with some rules
of thumb when to use which? Those will help me to understand the
difference.

Regards,
--
Nils Goesche
Ask not for whom the <CONTROL-G> tolls.

PGP key ID 0x42B32FC9

______________________________________________________________________
Posted Via Uncensored-News.Com - Still Only $9.95 - http://www.uncensored-news.com
With NINE Servers In California And Texas - The Worlds Uncensored News Source

Bulent Murtezaoglu

unread,
Feb 16, 2002, 11:38:06 PM2/16/02
to
>>>>> "NG" == Nils Goesche <car...@cartan.de> writes:

NG> Hi! I always find myself think very hard about when to use
NG> proclaim or declaim. [...]

There's a good note at the end of:

http://www.xanalys.com/software_tools/reference/HyperSpec/Body/f_procla.htm#proclaim

Hit that + the page for declaim and you'll be happier, I think. I was.

cheers,

BM


Tim Bradshaw

unread,
Feb 17, 2002, 5:24:33 AM2/17/02
to
* Nils Goesche wrote:

> I always find myself think very hard about when to use proclaim or
> declaim. Obviously there is something I don't understand about
> this. Could somebody be so kind as providing me with some rules
> of thumb when to use which? Those will help me to understand the
> difference.

I think it is as simple as an EVAL-WHEN in DECLAIM, so the compiler
hears it at top level. So if you want to make a top-level declaration
which is observed at compile-time, you want to use DECLAIM.

--tim

Nils Goesche

unread,
Feb 17, 2002, 4:52:09 PM2/17/02
to

Hm, yes, I guessed that DECLAIM is just PROCLAIM with an eval-when,
the HyperSpec makes that pretty clear. But I am still not sure which
one to use for global type declarations. Is this fine:

(defparameter *seed-size* 192
"The size of the SEED value (in bits) used by gen-primes.
A fixnum >= 160. Corresponds to g in DSS.")

(proclaim '(type (fixnum 160) *seed-size*))

?

Bulent Murtezaoglu

unread,
Feb 17, 2002, 5:38:50 PM2/17/02
to
>>>>> "NG" == Nils Goesche <car...@cartan.de> writes:
[...]
NG> (defparameter *seed-size* 192 "The size of the SEED value (in
NG> bits) used by gen-primes. A fixnum >= 160. Corresponds to g
NG> in DSS.")

NG> (proclaim '(type (fixnum 160) *seed-size*))

The proclaim does nothing at compile time IMHO. You probably want declaim
there

(declaim (type (fixnum 160) *seed-size*))

cheers,

BM


Pierre R. Mai

unread,
Feb 17, 2002, 5:40:44 PM2/17/02
to
Nils Goesche <car...@cartan.de> writes:

> Hm, yes, I guessed that DECLAIM is just PROCLAIM with an eval-when,
> the HyperSpec makes that pretty clear. But I am still not sure which
> one to use for global type declarations. Is this fine:
>
> (defparameter *seed-size* 192
> "The size of the SEED value (in bits) used by gen-primes.
> A fixnum >= 160. Corresponds to g in DSS.")
>
> (proclaim '(type (fixnum 160) *seed-size*))

Simple convenience suggests that you should use declaim, when the
declaration argument doesn't need to be evaluated (i.e. is constant),
so I'd prefer

(declaim (type (fixnum 160) *seed-size*))

Furthermore, it is not unlikely that you want to communicate your
type knowledge mostly to the compiler, and not just to the runtime
environment, so again, I'd prefer declaim.

Regs, Pierre.

--
Pierre R. Mai <pm...@acm.org> http://www.pmsf.de/pmai/
The most likely way for the world to be destroyed, most experts agree,
is by accident. That's where we come in; we're computer professionals.
We cause accidents. -- Nathaniel Borenstein

Tim Bradshaw

unread,
Feb 17, 2002, 5:50:17 PM2/17/02
to
* Nils Goesche wrote:
> Hm, yes, I guessed that DECLAIM is just PROCLAIM with an eval-when,
> the HyperSpec makes that pretty clear. But I am still not sure which
> one to use for global type declarations. Is this fine:

> (defparameter *seed-size* 192
> "The size of the SEED value (in bits) used by gen-primes.
> A fixnum >= 160. Corresponds to g in DSS.")

> (proclaim '(type (fixnum 160) *seed-size*))

I *think* that if you wanted the compiler to take advantage of this
before the file is loaded then you'd need to use DECLAIM. Given that,
say,

(proclaim
(function-not-defined-at-compile-time-which-returns-type-spec))

is OK, then unless the compiler does special magic on literal
arguments to PROCLAIM, then you really need to use DECLAIM. I think
that the issue is really that the compiler should not need to take
special note of PROCLAIM whereas in CLtL1 CL it did or may have had to
(I don't have a copy of any CLtL to hand to check unfortunately).

I'm sure someone can give a much better and more authoritative answer
than my vague wittering though.

--tim

Nils Goesche

unread,
Feb 17, 2002, 7:08:40 PM2/17/02
to
In article <87eljju...@orion.bln.pmsf.de>, Pierre R. Mai wrote:
> Nils Goesche <car...@cartan.de> writes:
>
>> Hm, yes, I guessed that DECLAIM is just PROCLAIM with an eval-when,
>> the HyperSpec makes that pretty clear. But I am still not sure which
>> one to use for global type declarations. Is this fine:
>>
>> (defparameter *seed-size* 192
>> "The size of the SEED value (in bits) used by gen-primes.
>> A fixnum >= 160. Corresponds to g in DSS.")
>>
>> (proclaim '(type (fixnum 160) *seed-size*))
>
> Simple convenience suggests that you should use declaim, when the
> declaration argument doesn't need to be evaluated (i.e. is constant),
> so I'd prefer
>
> (declaim (type (fixnum 160) *seed-size*))
>
> Furthermore, it is not unlikely that you want to communicate your
> type knowledge mostly to the compiler, and not just to the runtime
> environment, so again, I'd prefer declaim.

Ah, thanks to everyone; I think I got it now.

Tim Bradshaw

unread,
Feb 18, 2002, 6:30:42 AM2/18/02
to
* Pierre R Mai wrote:

> Furthermore, it is not unlikely that you want to communicate your
> type knowledge mostly to the compiler, and not just to the runtime
> environment, so again, I'd prefer declaim.

I thought about this a bit, and I'm now confused. Imagine a situation
like this:

(defvar *foo* (big-complicated-function))

(declaim (type fixnum) *foo*)

Can this code be correct? I'm not sure it can, because at compile
time, *FOO* is not yet defined (the compiler knows about it, but I
don't think the system is really entitled to call
BIG-COMPLICATED-FUNCTION until load time - in particular
BIG-COMPLICATED-FUNCTION may not be defined at compile time. So the
type declaration can't (or may not) be true at compile time, I think.

I'm not really sure I understand this at all though.

--tim

Jochen Schmidt

unread,
Feb 18, 2002, 7:57:15 AM2/18/02
to
Tim Bradshaw wrote:

I would say that you declare this assertion also to be true at
compile-time. So if some compile-time computation accesses *foo* it will
fail through a typecheck or crash and burn (depending on the safety
settings...). If some compile-time computation sets *foo* to a fixnum
before using it otherwise, the generated code will run ok even if it takes
the assertion to be true.

But maybe I have simply overseen the real point of your question...

ciao,
Jochen


--
http://www.dataheaven.de

Erik Naggum

unread,
Feb 18, 2002, 7:06:30 AM2/18/02
to
* Tim Bradshaw <t...@cley.com>

| I thought about this a bit, and I'm now confused. Imagine a situation
| like this:
|
| (defvar *foo* (big-complicated-function))
|
| (declaim (type fixnum) *foo*)
|
| Can this code be correct?

Yes. It would be even if you switched the two top-level forms.

| I'm not sure it can, because at compile time, *FOO* is not yet defined

Of course it is. defvar must affect the compilation environment at least
to the extent that it remembers that *foo* is a special variable.
However, it does not necessarily have a _value_ until load-time.

| So the type declaration can't (or may not) be true at compile time, I
| think.

The declarations are associated with the symbols, not with the bindings,
but they affect the bindings because of the declarations associated with
the symbol.

///
--
In a fight against something, the fight has value, victory has none.
In a fight for something, the fight is a loss, victory merely relief.

Tim Bradshaw

unread,
Feb 18, 2002, 7:40:06 AM2/18/02
to
* Erik Naggum wrote:

> Of course it is. defvar must affect the compilation environment at least
> to the extent that it remembers that *foo* is a special variable.
> However, it does not necessarily have a _value_ until load-time.

yes, this is obviously correct, I think (so I was indeed confused, and
wrong). *FOO* isn't bound at compile time then the declaration says
that if it *becomes* bound that binding will have a certain type (this
is horribly imprecise terminology).

--tim

Erik Naggum

unread,
Feb 18, 2002, 10:36:42 AM2/18/02
to
* Tim Bradshaw <t...@cley.com>

| yes, this is obviously correct, I think (so I was indeed confused, and
| wrong). *FOO* isn't bound at compile time then the declaration says that
| if it *becomes* bound that binding will have a certain type (this is
| horribly imprecise terminology).

I think what it says is that every reference to that variable has the
right to assume that it read as if (the fixnum *foo*). *foo* need not
be bound for this to compile, either.

0 new messages