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

Gary Byers gb at clozure.com
Sun Oct 20 16:38:17 PDT 2002



On Sun, 20 Oct 2002, Kevin Rosenberg wrote:

> Hello, I'd like to find out how to get the names of slots in a
> structure. I have the following function that I'd like to get
> supported in OpenMCL:
>

This quietly returns NIL if S-NAME doesn't name a structure class.

(defun structure-slot-names (s-name)
  "Given a STRUCTURE-NAME, returns a list of the slots in the
  structure."
  #+allegro (class-slot-names s-name)
  #+lispworks (structure:structure-class-slot-names
	       (find-class s-name))
  #+sbcl (mapcar #'sb-pcl::slot-definition-name
		 (sb-pcl:class-slots
		  (sb-pcl:find-class s-name)))
  #+cmu (mapcar
	 #'pcl::slot-definition-name
	 (pcl:class-slots (pcl:find-class s-name)))
  #+scl
  (loop as
	s across
	(kernel::layout-slots
	 (slot-value (find-class s-name) 'clos::layout))
	collecting s)
  #+mcl (let* ((sd (gethash s-name ccl::%defstructs%))
               (slots (if sd (ccl::sd-slots sd))))
          (mapcar #'car (if (symbolp (caar slots)) slots (cdr slots))))
  #-(or allegro lispworks cmu sbcl scl mcl)
  (error "structure-slot-names is not defined on this platform")
  )
>
> Thanks!
> --
>        Kevin Rosenberg        |  .''`.  ** Debian GNU/Linux **
>   http://b9.com/debian.html   | : :' :      The  universal
>   GPG signed and encrypted    | `. `'      Operating System
>      messages accepted.       |   `-    http://www.debian.org/
>
> _______________________________________________
> 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