[Openmcl-devel] How to get names of slots of a structure?

Gary Byers gb at clozure.com
Sun Oct 20 19:32:38 PDT 2002



On Sun, 20 Oct 2002, Kevin Rosenberg wrote:

> Gary Byers wrote:
> > This quietly returns NIL if S-NAME doesn't name a structure class.
> >
> > (defun structure-slot-names (s-name)
>
> Great -- thanks, Gary!
>
> That's just what I needed. I was hoping that I would be be able to
> figure out analagous code to handle the function CLASS-SLOT-NAMES
> which takes a symbol for the class-name and returns a list of symbols
> naming the class members.
>
> May I trouble you for the code for that as well?
>

;;; I -think- this is right ...
;;; You may or may not be interested in the shared (class) slot names.
;;; This should work the same way in both commercial MCL and OpenMCL.

#+mcl
(defun class-slot-names (class-name)
  (let* ((class (find-class class-name nil)))
    (when (typep class 'standard-class)
      (append (map 'list #'car (ccl::%class-instance-slotds class))
              (map 'list #'car (ccl::%class-shared-slotds class))))))

> This is for a lisp package that I wrote on contract and hope to get
> made open-source. I'd like for it to support openmcl.
>

Great!  Good luck.


> Kevin
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/cgi-bin/mailman/listinfo/openmcl-devel
>
>


_______________________________________________
Openmcl-devel mailing list
Openmcl-devel at clozure.com
http://clozure.com/cgi-bin/mailman/listinfo/openmcl-devel



More information about the Openmcl-devel mailing list