From: Nils Goesche
Subject: declaim? proclaim?
Date: 
Message-ID: <3c6f305e$1_4@news2.uncensored-news.com>
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
  

From: Bulent Murtezaoglu
Subject: Re: declaim? proclaim?
Date: 
Message-ID: <874rkgk9jq.fsf@nkapi.internal>
>>>>> "NG" == Nils Goesche <······@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

 
From: Tim Bradshaw
Subject: Re: declaim? proclaim?
Date: 
Message-ID: <ey3ofio2you.fsf@cley.com>
* 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
From: Nils Goesche
Subject: Re: declaim? proclaim?
Date: 
Message-ID: <3c702607$1_7@news4.uncensored-news.com>
In article <···············@cley.com>, Tim Bradshaw wrote:
> * 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.

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*))

?

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
  
From: Bulent Murtezaoglu
Subject: Re: declaim? proclaim?
Date: 
Message-ID: <871yfjka2s.fsf@nkapi.internal>
>>>>> "NG" == Nils Goesche <······@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
From: Tim Bradshaw
Subject: Re: declaim? proclaim?
Date: 
Message-ID: <ey34rkf3eqe.fsf@cley.com>
* 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
From: Pierre R. Mai
Subject: Re: declaim? proclaim?
Date: 
Message-ID: <87eljju3yr.fsf@orion.bln.pmsf.de>
Nils Goesche <······@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 <····@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
From: Nils Goesche
Subject: Re: declaim? proclaim?
Date: 
Message-ID: <3c704608$1_4@news4.uncensored-news.com>
In article <··············@orion.bln.pmsf.de>, Pierre R. Mai wrote:
> Nils Goesche <······@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.

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
  
From: Tim Bradshaw
Subject: Re: declaim? proclaim?
Date: 
Message-ID: <ey3pu3310yl.fsf@cley.com>
* 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
From: Erik Naggum
Subject: Re: declaim? proclaim?
Date: 
Message-ID: <3223022793121740@naggum.net>
* Tim Bradshaw <···@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.
From: Tim Bradshaw
Subject: Re: declaim? proclaim?
Date: 
Message-ID: <ey3lmdr0xqx.fsf@cley.com>
* 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
From: Erik Naggum
Subject: Re: declaim? proclaim?
Date: 
Message-ID: <3223035405814028@naggum.net>
* Tim Bradshaw <···@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.

///
-- 
  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.
From: Jochen Schmidt
Subject: Re: declaim? proclaim?
Date: 
Message-ID: <a4qq2d$44j$1@rznews2.rrze.uni-erlangen.de>
Tim Bradshaw wrote:

> * 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.

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