🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.clos
Article #151

a defclass helper

#151
From: Clinton Hyde
Date: Wed, 19 Aug 1992 23:36
55 lines
1870 bytes
here's a convenient helper which makes writing defclass forms MUCH
easier.


;;;a quickie macro which renders defclass forms from a much simpler version.

(DEFMACRO dclass (name incl slots &rest options)
  `(DEFCLASS ,name ,incl ,(MAPCAR #'(lambda (slot)
				      (if (listp slot)
					  slot
					(LIST slot 
					      :initform ()
					      :initarg (INTERN (STRING slot) :keyword)
					      :accessor slot)))
				slots)
     ,@options))


usage is:

(dclass cdp-base nil (name highlighted owner parent output-record
			explanation))

this expands to

(defclass cdp-base () 
 ((name :initform () :initarg :name :accessor name)
  ...))

__OR__

(dclass cdp-base nil (name 
			(some-slot :initform (do-something) :accessor get-some-slot)
			explanation))

which expands to

(defclass cdp-base () 
 ((name :initform () :initarg :name :accessor name)
  (some-slot :initform (do-something) :accessor get-some-slot)
  ...))

i'm using this a lot these days. I hate typing all that really obvious
extra garbage--FLAVORS managed to default things the right all the
time (auto-built accessors, etc), and I'd like CLOS to do so too.

 -- clint
--

Clint Hyde		"Give me a LispM or give me death!" -- anonymous

Advanced Decision Systems	Internet:  chyde@chesapeake.ads.com
2111 Wilson Blvd #800
Arlington, VA 22201		(703) 875-0327
Technical Details
Message-ID: <CHYDE.92Aug19183602@pecos.ads.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!convex!darwin.sura.net!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!ames!ads.com!chesapeake.ads.com!chesapeake!chyde

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!convex!darwin.sura.net!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!ames!ads.com!chesapeake.ads.com!chesapeake!chyde
From: chyde@pecos.ads.com (Clinton Hyde)
Newsgroups: comp.lang.clos
Subject: a defclass helper
Message-ID: <CHYDE.92Aug19183602@pecos.ads.com>
Date: 19 Aug 92 23:36:02 GMT
Sender: usenet@chesapeake.ads.com (USENET News)
Distribution: comp
Organization: Advanced Decision Systems, Mountain View, CA 94043, +1 (415)
 960-7300
Lines: 55