[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: CLOS question (or bug?)
- To: info-mcl
- Subject: Re: CLOS question (or bug?)
- From: rwk@crl.dec.com (Bob Kerns)
- Date: 5 Nov 91 16:24:06 GMT
- Newsgroups: comp.lang.lisp.mcl
- Organization: DEC Cambridge Research Lab
- References: <9111051511.AA22012@farallon.com>
- Sender: news@crl.dec.com (USENET News System)
In article <9111051511.AA22012@farallon.com>, Danny_Brewer@alinkgateway.farallon.com ("Danny Brewer") writes:
>
> Later, during an interactive programming session, I decide that const1
> shouldn't be 123 but should be 456. So I re-select and enter the class
> definition above, but with the corrected constant.
>
> And they STILL don't have the value of the new constant. Please correct me
> if I'm wrong, I'm new to CLOS, but I would consider this a bug.
It's not a bug. The slot is shared, and is initialized the first
time you create an instance, if not before (i.e. when you first
define the class). Redefining the class doesn't change it, any more
than :INITFORM in an instance-allocated slot changes the value in the
instances. :INITFORM specifies the *INITIAL* value, just as its name
is intended to suggest.
:INITFORM is handled exactly consistently between :ALLOCATION :CLASS
and :ALLOCATION :INSTANCE.
> By experimenting I've discovered that if I redefine the class WITHOUT the
> :ALLOCATION :CLASS and then redefine it with :ALLOCATION :CLASS, the
> new "constant" is immediately in effect without having to reinstantiate
> the two instances.
Well, if you remove the slot, and the add it back again, of course
you get the new initial value, so this doesn't conflict with what
I said above.
But what you really wanted to do is to set its value. This is,
of course, exactly how you change any other slot's value.
You can define a writer, or you can do SETF of SLOT-VALUE,
or set it in a method inside WITH-SLOTS, or you can even give
it a :INITARG and specify a new value in any call to MAKE-INSTANCE,
although that's sort of a wierd thing to do in my opinion.
Hope that helps.
> But wait, that's not all...
...but I'll leave the rest for someone else to explain.