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


Category:       CLARIFICATION
Edit history:   Revision 1 by Skona Brittain 07/26/88

Problem Description:

The case of a structure type being redefined is not discussed in CLtL.


It is an error to redefine a structure.


Redefining a structure is ok but it is an error to access, in any way,
an instance of the structure that was created prior to the redefinition.
This applies to instances of other structures that :INCLUDEd the 
redefined structure. 
It is also an error to use any of the redefined structures accessors
on any instances of a structure that :INCLUDEd the previous definition.

Test Cases:

(defstruct struc1
   slot1 slot2)
(setq s (make-struc1 :slot1 1 :slot2 2))
(defstruct struc1  ; this is an error according to ERROR-BY-ITSELF
   slot2 slot1)    ;          but not according to ERROR-IFF-USE
(struc1-slot1 s)   ; this is an error according to ERROR-IFF-USE

(defstruct struc1
   slot1 slot2)
(defstruct (struc2 (:include struc1))
  slot 3)
(defstruct struc1
  slot2 slot1)
(setq s (make-struc2 :slot1 1 :slot2 2))
(struc1-slot1 s)   ; this is an error according to ERROR-IFF-USE


The issue of redefinition should be addressed since there are always 
consequences that affect use of the structures: at the very least, 
the constructor function gets overwritten when a structure is redefined.

ERROR-BY-ITSELF is simpler, but ERROR-IFF-USED is more amenable to use.

Current Practice:

None of KCL, Lucid, & Symbolics detect a redefinition, but all of them
return 2 as the value of the last forms in each of the above test case sets.

Cost to Implementors:

ERROR-ITSELF:  none if not signaled. extremely slight if signaled.

ERROR-IFF-OLD-USE:  none if not signaled. much more if signaled.

Cost to Users:

ERROR-ITSELF:  It can be quite inconvenient to be prevented from "correcting"
a structure definition, which would presumably happen if the error were 


Cost of Non-Adoption:





Something that is not well-defined and leads to erratic behavior 
should be explicitly considered an error.


Larry supports ERROR-BY-ITSELF, "in that slot-accessors for structures are 
presumed to be declared "inline".  If users want more flexibility than that, 
they should use defclass."

Various inbetween proposals are possible, such as only incompatible 
redefinitions cause errors, but they're too hard to define.

My feeling is that it's a cop-out to just say it's an error to redefine
a structure but then never signal the error - users will still be confused
by the differing seemingly erratic behavior and code.