From: ···········@gmail.com
Subject: defparameter VS. defvar / setf
Date: 
Message-ID: <1173031152.532101.272630@30g2000cwc.googlegroups.com>
Hi,

The expression
          (defparameter *name* initial-value)
unconditionally evaluates initial-value and then assigns its result to
*name*

Contrasting, the expression
          (defvar *name* initial-value)
will only evaluate initial-value and assign its result to *name* if
the latter is not already bound.

So, are the following two possibilities equivalent?
1:       (defparameter *name* "Joubert Nel")

2:       (defvar *name*)
          (setf *name* "Joubert Nel")

and, as a 3rd possibility,assuming *name* is not already bound, then
either (defparameter  ...) or (defvar ...) would be OK.
The latter saves on some wrist-action :-)

If this is all so, I'm wondering why you would (defvar ....) a
variable if it is already in use except perhaps to change its
documentation? Perhaps I just haven't run into situations where this
is useful...

Joubert

From: Barry Margolin
Subject: Re: defparameter VS. defvar / setf
Date: 
Message-ID: <barmar-0F1DF5.13264804032007@comcast.dca.giganews.com>
In article <························@30g2000cwc.googlegroups.com>,
 ···········@gmail.com wrote:

> Hi,
> 
> The expression
>           (defparameter *name* initial-value)
> unconditionally evaluates initial-value and then assigns its result to
> *name*
> 
> Contrasting, the expression
>           (defvar *name* initial-value)
> will only evaluate initial-value and assign its result to *name* if
> the latter is not already bound.
> 
> So, are the following two possibilities equivalent?
> 1:       (defparameter *name* "Joubert Nel")
> 
> 2:       (defvar *name*)
>           (setf *name* "Joubert Nel")

Yes.

> 
> and, as a 3rd possibility,assuming *name* is not already bound, then
> either (defparameter  ...) or (defvar ...) would be OK.
> The latter saves on some wrist-action :-)
> 
> If this is all so, I'm wondering why you would (defvar ....) a
> variable if it is already in use except perhaps to change its
> documentation? Perhaps I just haven't run into situations where this
> is useful...

This happens all the time when you reload the entire file, presumably to 
fix a bug in one of the functions.  You don't want the reload to set 
variables back to their default values when the user has customized them.

-- 
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
From: Ken Tilton
Subject: Re: defparameter VS. defvar / setf
Date: 
Message-ID: <GqFGh.3308$%I4.3228@newsfe12.lga>
Barry Margolin wrote:
> In article <························@30g2000cwc.googlegroups.com>,
>  ···········@gmail.com wrote:
> 
> 
>>Hi,
>>
>>The expression
>>          (defparameter *name* initial-value)
>>unconditionally evaluates initial-value and then assigns its result to
>>*name*
>>
>>Contrasting, the expression
>>          (defvar *name* initial-value)
>>will only evaluate initial-value and assign its result to *name* if
>>the latter is not already bound.
>>
>>So, are the following two possibilities equivalent?
>>1:       (defparameter *name* "Joubert Nel")
>>
>>2:       (defvar *name*)
>>          (setf *name* "Joubert Nel")
> 
> 
> Yes.
> 
> 
>>and, as a 3rd possibility,assuming *name* is not already bound, then
>>either (defparameter  ...) or (defvar ...) would be OK.
>>The latter saves on some wrist-action :-)
>>
>>If this is all so, I'm wondering why you would (defvar ....) a
>>variable if it is already in use except perhaps to change its
>>documentation? Perhaps I just haven't run into situations where this
>>is useful...
> 
> 
> This happens all the time when you reload the entire file, presumably to 
> fix a bug in one of the functions.  You don't want the reload to set 
> variables back to their default values when the user has customized them.
> 

Right. A softer reason is the self-documenting quality that says (when 
the variable goes uninitialized) that this bad boy is bound dynamically 
at run time.

kt

-- 
Well, I've wrestled with reality for 35 years, Doctor, and
I'm happy to state I finally won out over it.
                                   -- Elwood P. Dowd

In this world, you must be oh so smart or oh so pleasant.
                                   -- Elwood's Mom
From: Vassil Nikolov
Subject: Re: defparameter VS. defvar / setf
Date: 
Message-ID: <yy8vps7ow78c.fsf@eskimo.com>
On Mon, 05 Mar 2007 09:45:10 +0530, Madhu <·······@meer.net> said:
| ...
| Except you can't set the documentation string if you want it to be
| uninitialized.

  But that is proper.  A docstring belongs with a definition, and a
  DEFVAR form that leaves a variable uninitialized isn't much of a
  definition.  As a matter of style, I believe that

    (declaim (special *foo*))

  is to be preferred to

    (defvar *foo*)  ;this variable intentionally left unbound

  (regrettably, I can't trace the origin of this advice to give proper
  credit).

  ---Vassil.


-- 
Is your code free of side defects?
From: Ken Tilton
Subject: Re: defparameter VS. defvar / setf
Date: 
Message-ID: <m%OGh.6213$%I4.1686@newsfe12.lga>
Vassil Nikolov wrote:
> On Mon, 05 Mar 2007 09:45:10 +0530, Madhu <·······@meer.net> said:
> | ...
> | Except you can't set the documentation string if you want it to be
> | uninitialized.
> 
>   But that is proper.  A docstring belongs with a definition, and a
>   DEFVAR form that leaves a variable uninitialized isn't much of a
>   definition.  As a matter of style, I believe that
> 
>     (declaim (special *foo*))

PWUAHAHAHAHHAHAHAHHHAHAHHHAHAHAAA!!!!!!

I thought I was anal.

> 
>   is to be preferred to
> 
>     (defvar *foo*)  ;this variable intentionally left unbound

Listen, when His Kennyness deigns to speak to you unworthies, just bow 
and scrape and leave the NG without turning your back on Himself. Do 
/not/ forget the offering plate.

docstrings? docstrings?!!!!!!! Read my lips: if you cannot name one 
frickin variable without creating confusion, can you imagine how much 
confusion you will create by writing a whole sentence?!!!

> 
>   (regrettably, I can't trace the origin of this advice to give proper
>   credit).

I found it!:

(defvar *cll-bozo-depth* 0 "OK, gosh, this is gonna be tricky, this is 
like, I am responding to a bozo, I mean, not how deep in the water they 
are depth, or how profound they are, but see, there was this other bozo 
I was responding to, ok, call that depth zero, and then a second bozo 
stepped in, hope that covers it, gotta run, pizza's here.")

Hmm, I like it, mebbe I was wrong. Nah, I was just inordinately precise 
and lucid compared to all the other doc I've ever read. Scary, that.

<There is so little hope for you people.>

kenny

-- 
Well, I've wrestled with reality for 35 years, Doctor, and
I'm happy to state I finally won out over it.
                                   -- Elwood P. Dowd

In this world, you must be oh so smart or oh so pleasant.
                                   -- Elwood's Mom
From: Ken Tilton
Subject: Re: defparameter VS. defvar / setf
Date: 
Message-ID: <9uWGh.24$R91.5@newsfe12.lga>
Madhu wrote:
> * Ken Tilton <·········@gmail.com> <···················@newsfe12.lga> :

> | <There is so little hope for you people.>
> 
> You'll feel much better once you've given up *all* hope

Lowered expectations (wants and desires) is definitely the buddhist way.

kt

-- 
Well, I've wrestled with reality for 35 years, Doctor, and
I'm happy to state I finally won out over it.
                                   -- Elwood P. Dowd

In this world, you must be oh so smart or oh so pleasant.
                                   -- Elwood's Mom
From: Tim Bradshaw
Subject: Re: defparameter VS. defvar / setf
Date: 
Message-ID: <eshv4o$fdl$2$8300dec7@news.demon.co.uk>
On 2007-03-05 13:54:53 +0000, Madhu <·······@meer.net> said:

> You'll feel much better once you've given up *all* hope

It's true.  I did, and I do.  I used to feel bad about making people 
into useful products, but no more.
From: Rob Warnock
Subject: Re: defparameter VS. defvar / setf
Date: 
Message-ID: <MdGdnbJulPlFxXPYnZ2dnUVZ_uHinZ2d@speakeasy.net>
Tim Bradshaw  <···@tfeb.org> wrote:
+---------------
| Madhu <·······@meer.net> said:
| > You'll feel much better once you've given up *all* hope
| 
| It's true.  I did, and I do.  I used to feel bad about
| making people into useful products, but no more.
+---------------

What, Soylent Green?


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Tim Bradshaw
Subject: Re: defparameter VS. defvar / setf
Date: 
Message-ID: <eslph6$nj3$2$8300dec7@news.demon.co.uk>
On 2007-03-07 06:16:56 +0000, ····@rpw3.org (Rob Warnock) said:

> What, Soylent Green?

Dogfood, glue, soap, armchairs (so, yes basically).
From: John Thingstad
Subject: Re: defparameter VS. defvar / setf
Date: 
Message-ID: <op.totbixwopqzri1@pandora.upc.no>
On Wed, 07 Mar 2007 08:27:33 +0100, Tim Bradshaw <···@tfeb.org> wrote:

> On 2007-03-07 06:16:56 +0000, ····@rpw3.org (Rob Warnock) said:
>
>> What, Soylent Green?
>
> Dogfood, glue, soap, armchairs (so, yes basically).
>

Film from the 1970's.

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
From: Tim Bradshaw
Subject: Re: defparameter VS. defvar / setf
Date: 
Message-ID: <esn4vk$ksp$2$8300dec7@news.demon.co.uk>
On 2007-03-07 09:33:59 +0000, "John Thingstad" <··············@chello.no> said:

> Film from the 1970's.

That's a good use!  Dunno about the backing but you certainly want gelatin.
From: John Thingstad
Subject: Re: defparameter VS. defvar / setf
Date: 
Message-ID: <op.totbqkpqpqzri1@pandora.upc.no>
On Wed, 07 Mar 2007 07:16:56 +0100, Rob Warnock <····@rpw3.org> wrote:

> Tim Bradshaw  <···@tfeb.org> wrote:
> +---------------
> | Madhu <·······@meer.net> said:
> | > You'll feel much better once you've given up *all* hope
> |
> | It's true.  I did, and I do.  I used to feel bad about
> | making people into useful products, but no more.
> +---------------
>
> What, Soylent Green?
>
>
> -Rob
>
> -----
> Rob Warnock			<····@rpw3.org>
> 627 26th Avenue			<URL:http://rpw3.org/>
> San Mateo, CA 94403		(650)572-2607
>

Yes, University's have turned into broiler factories to produce qualifed  
workers.
What happened to the institution that loved knowledge for it's own sake?
Are we all complacent being a pawn in a politicians game?

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
From: George Neuner
Subject: Re: defparameter VS. defvar / setf
Date: 
Message-ID: <abs3v2d2p9vhbpvg0396bnncg1vck1n9tf@4ax.com>
On Wed, 07 Mar 2007 10:38:34 +0100, "John Thingstad"
<··············@chello.no> wrote:

>
>Yes, University's have turned into broiler factories to produce qualifed  
>workers.
>What happened to the institution that loved knowledge for it's own sake?
>Are we all complacent being a pawn in a politicians game?

Nurse:   "Doctor, the monitor shows brain activity."
Doctor:  "Give the patient a blue pill, that should stop it."


George
--
for email reply remove "/" from address
From: GP lisper
Subject: Re: defparameter VS. defvar / setf
Date: 
Message-ID: <slrnevdn78.7rj.spambait@phoenix.clouddancer.com>
On Wed, 07 Mar 2007 10:38:34 +0100, <··············@chello.no> wrote:
>
> Are we all complacent being a pawn in a politicians game?

They took our guns away, but kept theirs...


-- 
There are no average Common Lisp programmers
Reply-To: email is ignored.

-- 
Posted via a free Usenet account from http://www.teranews.com
From: Alain Picard
Subject: Re: defparameter VS. defvar / setf
Date: 
Message-ID: <87k5xuabyw.fsf@memetrics.com>
Madhu <·······@meer.net> writes:

>
> Except you can't set the documentation string if you want it to be
> uninitialized.
>
> (defvar *foo*) ; unbound
> (setf (documentation '*foo* 'variable) "Bound dynamically at runtime.
> Do not bind this at the global toplevel !!!")
>
> I always found this clunky.

That's why you wrap that in a macro, DEFVAR-UNBOUND, which does
precisely that.   :-)

e.g.

(defvar-unbound *modlisp-headers*
  "Current modlisp headers for this request.")