Re: with-slots usage question
Miles Egan <[email protected]> Mon, 10 Nov 2003 10:38:33 -0800
| Newsgroups | gmane.lisp.clump |
|---|---|
| Message-ID | <1068489513.25524.33.camel@car> |
On Mon, 2003-11-10 at 10:15, Peter Seibel wrote: > > I considered doing this, but I usually tend to use accessors like > > class-field (message-subject, message-author, etc in macho, for > > instance). Maybe this is bad form? > > There's a school of thought (which I happen to subscribe to) that says > it is bad form. If you name your accesors this way, then when you > write subclasses the names expose what level of the class hierarchy > the accessors were defined in: > > (defclass foo () > ((x :accessor foo-x))) > > (defclass bar (foo) > ((y :accessor bar-y))) > > (let ((b (make-instance 'bar))) > (setf (foo-x b) 10) ; ugly, I think > (setf (bar-y b) 20)) > > The other point--which is sort of theoretical--is that when you are > defining an accessor you are really defining a generic function (and a > method specialized on this class). And GF's should really be viewed as > existing independently of classes, therefore should be named in > class-neutral ways. Really revealing my ignorance wrt CLOS here (I guess I should actually *read* the Keene book I've had on my shelf for years now), but isn't it a problem if you try to define a generic function if there's already a regular function by that name? The reason I've been prepending the base-class name to my accessor functions is that I've been worried about defining functions like name, size, length, etc. -- Miles Egan <[email protected]> _______________________________________________ Clump mailing list [email protected] http://manly.caddr.com/mailman/listinfo/clump
signature.asc
(application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQA/r9soU4Jq/wH1PVERAkTrAJ91Va1/vmbL1WN9RS8VEY3B3CwcagCePJpJ tT4FSSsCvI8Pwvw3bt0uZDQ= =a1/5 -----END PGP SIGNATURE-----