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

DEFSTRUCT and DEFCLASS



I'm confused about the use of metaclass STRUCTURE-CLASS; a cleanup
proposal to clarify this is needed.  In X3J13 correspondence, I've seen
mentions of using DEFCLASS instead of DEFSTRUCT to create structures,
but document 88-002R does not say that you can do that.  On the other
hand, it doesn't say that you can't either.  Basically the question is
whether
  (DEFSTRUCT ... (:METACLASS STRUCTURE-CLASS))
is legal and, if so, just what it means.

What the document _does_ say on page 1-15:

  "Calling MAKE-INSTANCE to create an instance of a built-in class
  signals an error.  Calling SLOT-VALUE on an instance of a built-in
  class signals an error."

No such error is specified for STRUCTURE-CLASS; is that intended to
imply that SLOT-VALUE of a structure _is_ legal?  Page 2-80 does not
shed any light on this.  It isn't until page 3-107 of document 89-003
that we see that, yes, it is supposed to be supported.

Also on page 1-15:

  "Calling MAKE-INSTANCE to create an instance of STRUCTURE-CLASS
  signals an error."

I had always thought that this meant that MAKE-INSTANCE couldn't be used
to create an instance of a structure type, but looking at it again now,
it looks like it just means that you can't create the structure type by
(MAKE-INSTANCE 'STRUCTURE-CLASS); perhaps a clarification of the wording
would be in order.  But since DEFCLASS uses ENSURE-CLASS which uses
MAKE-INSTANCE, does that imply that DEFCLASS can't be used either?

Page 3-35 of 89-003 does specify an ALLOCATE-INSTANCE method for
STRUCTURE-CLASS, which would imply that MAKE-INSTANCE _can_ be used to
create instances of structure types.

But if chapter 3 is not going to make it into the standard, then it is
even more important to clarify this in chapters 1 and 2  -- is the use
of DEFCLASS, MAKE-INSTANCE, SLOT-VALUE etc. for structures

  * Required to be supported?   or

  * Required to signal an error?  or

  * A permissible extension?

Also, if (DEFSTRUCT ... (:METACLASS STRUCTURE-CLASS)) is permitted, what
limitations or extensions apply to the slot and class options?  Does it
create a MAKE-... function?  Does it accept a :CONSTRUCTOR class option?
What kind of accessors does it create -- inline functions like
DEFSTRUCT, or generic function methods like STANDARD-CLASS?  
Is :ALLOCATION :CLASS permitted?