From: Lieven
Subject: structure inheritance
Date: 
Message-ID: <41afca39$0$9317$ba620e4c@news.skynet.be>
I've got a Lisp library with a structure 'problem'.
I want to do the following:

(defstructure (pop-problem
                (:include problem)
                (:constructor create-pop-problem)))

But besides this, I also want to add an extra slot to my pop-problem.
According to http://defstruct, I understand this should be:

(defstructure (pop-problem
                (:include problem (possible-ops :initform NIL))
                (:constructor create-pop-problem)))

But this doesn't seem to work.

From: Paul F. Dietz
Subject: Re: structure inheritance
Date: 
Message-ID: <vrGdnXNzv-8mSDLcRVn-pA@dls.net>
Lieven wrote:
> I've got a Lisp library with a structure 'problem'.
> I want to do the following:
> 
> (defstructure (pop-problem
>                 (:include problem)
>                 (:constructor create-pop-problem)))
> 
> But besides this, I also want to add an extra slot to my pop-problem.
> According to http://defstruct, I understand this should be:
> 
> (defstructure (pop-problem
>                 (:include problem (possible-ops :initform NIL))
>                 (:constructor create-pop-problem)))
> 
> But this doesn't seem to work.

In Common Lisp, it's DEFSTRUCT, not DEFSTRUCTURE, and there's
no :INITFORM keyword.  Moreover, putting slots there is just to
override slot properties of inherited slots.  New slots go a level
up, after the (pop-problem ...) list:

(defstruct (pop-problem (:include problem) (:constructor create-pop-problem))
     (possible-ops nil))

	Paul
From: Barry Margolin
Subject: Re: structure inheritance
Date: 
Message-ID: <barmar-A5D046.22030702122004@comcast.dca.giganews.com>
In article <························@news.skynet.be>,
 Lieven <···············@hotmail.com> wrote:

> I've got a Lisp library with a structure 'problem'.
> I want to do the following:
> 
> (defstructure (pop-problem
>                 (:include problem)
>                 (:constructor create-pop-problem)))

How does your DEFSTRUCTURE macro relate to the standard DEFSTRUCT macro?

> 
> But besides this, I also want to add an extra slot to my pop-problem.
> According to http://defstruct, I understand this should be:
> 
> (defstructure (pop-problem
>                 (:include problem (possible-ops :initform NIL))
>                 (:constructor create-pop-problem)))
> 
> But this doesn't seem to work.

That syntax is used to modify the slot options of slots that are 
inherited.  If you want to add additional slots, you do that in the body 
of the DEFSTRUCT:

(defstruct (pop-problem
             (:include problem)
             (:constructor create-pop-problem))
  (possible-ops nil))

Also, the initial value of a slot is not specifies using :INITFORM 
(that's the DEFCLASS syntax), it's done simply by putting the initial 
value after the slot name, as shown above.  Keyworded slot options 
follow that -- the only standard ones are :TYPE and :READ-ONLY.

-- 
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
From: Lieven
Subject: Re: structure inheritance
Date: 
Message-ID: <41b05cff$0$25044$ba620e4c@news.skynet.be>
Thanks. I got my structure working.