Re: with-slots usage question

Miles Egan <[email protected]> Mon, 10 Nov 2003 10:02:37 -0800
Newsgroups gmane.lisp.clump
Message-ID <1068487357.25524.15.camel@car>
On Mon, 2003-11-10 at 09:12, Peter Seibel wrote:
> Miles Egan <[email protected]> writes:
> 
> > Since discovering with-slots I've started using it pretty heavily in my
> > code since it really cuts down the verbosity of clos-based code.  It
> > makes me a little uneasy that with-slots goes directly to the slot value
> > without using an accessor though.  I suppose the more proper thing would
> > be to use with-accessors but it seems so much more verbose.
> > 
> > The ideal thing would be a with-? macro that's as terse as with-slots
> > but does invoke accessor functions.  Does such a macro exist?  Would it
> > be possible to write one without using the MOP?
> 
> Assuming you're happy to live with the variable names matching the
> accessor names, doesn't this do what you want? (Coming up with a
> better name than with-foo is left as an exercise for the reader):
> 
>   (defmacro with-foo ((&rest names) obj &body body)
>     `(with-accessors ,(mapcar #'(lambda (n) (list n n)) names) ,obj
>        ,@body))

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?

The biggest problem I have with the above is that even if I can assume
it will work with my own code I can't guarantee it will work with
someone else that's used different naming conventions.

-- 
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/r9K9U4Jq/wH1PVERAl/RAJ9gh2Q/PhmW3/Xouz1rdYyZFzFErQCcDNLF
xeYUe+50khVELYetC7ZtK+A=
=H2rI
-----END PGP SIGNATURE-----