From: Andreas Hinze
Subject: CLOS Question: Acessing class information
Date:
Message-ID: <3D2C28A1.AE7E9159@smi.de>
Hi all.
Maybe a nerd question but is it possible to access (meta-) information
about classes in CLOS ?
I.e:
>(defclass foo ()
((foovar ...)))
>(defclass subfoo (foo)
((subvar ...)))
>(SLOTS-OF-CLASS 'foo) ;nice to have
--> (foovar ...)
>(SUPERCLASS 'subfoo) ;nice to have
--> (foo)
I want to extract these information in a way that can
be used by other functions (i.e documentation tools).
Thanks in advance.
Best
AHz
Andreas Hinze <···@smi.de> writes:
> Maybe a nerd question but is it possible to access (meta-) information
> about classes in CLOS ?
Use the Metaobject Protocol (MOP). It is not a standard part of
Common Lisp, but AFAIK common regardless.
> >(SLOTS-OF-CLASS 'foo) ;nice to have
> --> (foovar ...)
In CMUCL:
(mapcar #'mop:slot-definition-name
(mop:class-slots (mop:find-class 'foo)))
;=> (FOOVAR)
> >(SUPERCLASS 'subfoo) ;nice to have
> --> (foo)
(mapcar #'mop:class-name
(mop:class-direct-superclasses (mop:find-class 'subfoo)))
;=> (FOO)
In SBCL, use the SB-PCL package instead.
In both SBCL and CMUCL, the MOP functions CLASS-NAME and FIND-CLASS
are different from those found in the standard COMMON-LISP package.
From: Andreas Hinze
Subject: Re: CLOS Question: Acessing class information
Date:
Message-ID: <3D2C34B9.9A00F7BF@smi.de>
Kalle Olavi Niemitalo wrote:
>
> In CMUCL:
>
> (mapcar #'mop:slot-definition-name
> (mop:class-slots (mop:find-class 'foo)))
> ;=> (FOOVAR)
>
> > >(SUPERCLASS 'subfoo) ;nice to have
> > --> (foo)
>
> (mapcar #'mop:class-name
> (mop:class-direct-superclasses (mop:find-class 'subfoo)))
> ;=> (FOO)
>
> In SBCL, use the SB-PCL package instead.
> In both SBCL and CMUCL, the MOP functions CLASS-NAME and FIND-CLASS
> are different from those found in the standard COMMON-LISP package.
Works perfect. Thank you very much.
Where can i find more information about that functions ?
Best
AHz
Andreas Hinze <···@smi.de> writes:
> Kalle Olavi Niemitalo wrote:
> >
> > In CMUCL:
> >
> > (mapcar #'mop:slot-definition-name
> > (mop:class-slots (mop:find-class 'foo)))
> > ;=> (FOOVAR)
> >
> > > >(SUPERCLASS 'subfoo) ;nice to have
> > > --> (foo)
> >
> > (mapcar #'mop:class-name
> > (mop:class-direct-superclasses (mop:find-class 'subfoo)))
> > ;=> (FOO)
> >
> > In SBCL, use the SB-PCL package instead.
> > In both SBCL and CMUCL, the MOP functions CLASS-NAME and FIND-CLASS
> > are different from those found in the standard COMMON-LISP package.
>
> Works perfect. Thank you very much.
> Where can i find more information about that functions ?
<http://www.elwoodcorp.com/alu/mop/>
Edi.
From: Andreas Hinze
Subject: Re: CLOS Question: Acessing class information
Date:
Message-ID: <3D2C3C57.BD3DA1B9@smi.de>
Edi Weitz wrote:
> > Works perfect. Thank you very much.
> > Where can i find more information about that functions ?
>
> <http://www.elwoodcorp.com/alu/mop/>
>
Thanks.
Best
AHz