Re: with-slots usage question
David Lichteblau <[email protected]> Mon, 10 Nov 2003 19:59:31 +0100
| Newsgroups | gmane.lisp.clump |
|---|---|
| Message-ID | <[email protected]> |
Quoting Miles Egan ([email protected]): > 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. Sure, so you end up with %name, %size, and %length. And don't forget the headache which results when you export these symbols, and the user of your package already had a function, generic or not, with the same name but different lambda list. Adding a class name prefix mostly solves these issues. Still it feels like a workaround, not like a solution. All in all I find CLOS quite attractive, but these are the occasional reminders that it requires careful interface design. Look at they problem they had with CORBA IDL attributes in the Common Lisp mapping. IDL purposely distinguishes between attributes and operations, since they map to different concepts in most languages. Instead of putting them into different Lisp packages (like at:attribute and op:operation), the designers of the IDL mapping chose to throw them together into the operation package. As a result, you cannot write (defclass corba-interface () ((attribute :accessor op:attribute))) since op:attribute's lambda list needs to work for non-reader operations too, and thus looks like (self &rest args). That IDL-mapping problem is solvable using a simple DEFCLASS wrapper. But then you end up wondering yourself why are typing ((blubba :initarg :blubba :accessor :blubba) (frobfrob :initarg :frobfrob :accessor :frobfrob) (blablabla :initarg :blablabla :accessor :blablabla)) all the time anyway, so you add yet another DEFCLASS wrapper. Explain that to a newbie. I have seen Lisp code which marks all accessors with a Java-style GET- prefix... :ACCESSOR GET-ATTRIBUTE. Ugly? Perhaps. But neither suprising nor absurd, I believe. _______________________________________________ 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) iD8DBQE/r+ARiGoiD4YyHUgRAsNZAKCCMf1r1YMi9g2oK6lB8rnN/HpZOQCeLhPx j0eWZ7Ix/Ul4cYGXiLnUsaI= =WOzy -----END PGP SIGNATURE-----