[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Questions: undefining stuff in MCL

At  6:20 AM 5/17/93 +0000, Cecil Huang wrote:
>Hello all,
>Thanks in advance for taking the time and trouble to help me out.  I am
>a new MCL user and I have some basic questions about undefining entities
>in MCL.  This is in the context of the following situations:
> 1.  Suppose I'm in MCL and I want to wipe out all of the definitions
>     I have created.  Is there any way to do this without quitting MCL
>     and restarting it?  I notice that when I close the "listener" window,
>     a new one appears, but it seems to "remember" everything from the
>     previous listener window.

An MCL Listener is a user interface for the Common Lisp heap.
Neither the Common Lisp specification nor MCL provide a notion of UNDO
or any kind of transaction protocol for the Common Lisp heap.

> 2.  In experimenting with OOP, I tried the following, in order:
>     [1]  (defstruct account (name "") (balance 0.00) (interest-rate .06))
>     Later, I decided I wanted to do try this example in CLOS and define
>     a class called account.
>     [2]  (defclass account ()
>            ((name :initarg :name :reader name)
>             (balance :initarg :balance :initform 0.00 :accessor balance)
>             (interest-rate :allocation :class :initform .06 
>                      :reader interest-rate)))
>     I got the following error message, which suggests that somehow [1]
>     prevented the successful execution of [2].  (I confirmed this by 
>     restarting MCL and executing [2] only, and it succeeded.)
>     > Error: #<STRUCTURE-CLASS ACCOUNT> is not an instance of
>     > While executing: CCL::%DEFCLASS
>     > Type Command-/ to continue, Command-. to abort.
>       See the RestartsI menu item for further choices.    
>     Can someone explain to me why this is happening and what I can do
>     about it?  (Could I "undefstruct" [1], for example?)

The CLOS spec does not in general allow a class'es metaclass to be
changed, though it does specify that this is an allowed extension
(CLtL2, section, p. 812). The AMOP is even weaker on this
point. It explicitly specifies this operation as having undefined

MCL signals an error to warn you that you are doing something unkosher,
but allows you to go ahead and perform the redefinition if you continue.
Typing command-/ will redefine the class, but it will not change the
class of any existing instances of #<STRUCTURE-CLASS ACCOUNT>.