>>>>> On Sat, 08 Jan 2011 18:07:48 +0300, Samium Gromoff said: > > On Sat, 8 Jan 2011 15:48:33 +0100, Pascal Costanza <p...@p-cos.net> wrote: > > > > On 8 Jan 2011, at 14:15, Samium Gromoff wrote: > > > > > On Fri, 7 Jan 2011 23:42:23 +0100, Pascal Costanza <p...@p-cos.net> wrote: > > >> There is no real advantage in having shared slots over global special > > >> variables. On top of that, the slot access protocols in the CLOS MOP > > >> also don't work that well in conjunction with shared slots. So it's > > >> better to avoid them. Fortunately, this is the only feature in CLOS that > > >> doesn't make any sense, as far as I can tell. > > > > > > This is sad, indeed, as shared slots could have been used to associate > > > information with sub-lattice of the class relationship lattice. I have > > > been tempted to do exactly this, multiple times, having, instead, to > > > resort to manual storage of this information. > > > > What exactly would you like to do? There are ways to do such things using > > the CLOS MOP... > > Ok, real world code, beware. While reading, only pay attention how > VCS-TYPE-MIXIN threads through the "slices". > > (defclass vcs-type-mixin () > (# the following slot is absent in real code, I have to emulate it > (enabled-p :accessor vcs-type-enabled-p :allocation :class) > (vcs-type :reader vcs-type :initarg :vcs-type))) > > ;;;;; VCS slice (protocol classes) > ;;; exhaustive partition of VCS-TYPE-MIXIN > (defclass git (vcs-type-mixin) () > (:default-initargs :vcs-type 'git)) > (defclass nongit-mixin () ()) > (defclass hg (vcs-type-mixin nongit-mixin) () > (:default-initargs :vcs-type 'hg)) > (defclass darcs (vcs-type-mixin nongit-mixin) () > (:default-initargs :vcs-type 'darcs)) > (defclass cvs (vcs-type-mixin wrinkle-mixin nongit-mixin) () > (:default-initargs :vcs-type 'cvs)) > (defclass svn (vcs-type-mixin wrinkle-mixin nongit-mixin) () > (:default-initargs :vcs-type 'svn)) > (defclass tarball (vcs-type-mixin nongit-mixin) () > (:default-initargs :vcs-type 'tarball)) > ... > (defun vcs-enabled-p (type) > "Problem function." > (class-slot type 'enabled-p)) > > ...I want to be able to use VCS-ENABLED-P on any slice before > instantiable classes are instantiated.
Another reason why this won't work is that you only have one slot -- the same value is shared between every subclass of vcs-type-mixin. Adding a separate slot to each subclass is a pain. -- Martin Simmons LispWorks Ltd http://www.lispworks.com/ _______________________________________________ pro mailing list pro@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/pro