Hi Francesco,

As Alessio states, CLOS out of the box doesn't support  arbitrary  
predicates for specializers (AFAIK, this is for efficiency concerns).  
You can use the MOP to manage this (and people have; see, for example, 
ftp://publications.ai.mit.edu/ai-publications/2001/AITR-2001-006.pdf) 
.

HTH,

On Jun 10, 2009, at 4:42 AM, Francesco Petrogalli wrote:

> Hi,
> I woud like to create new specializer for my object system:
>
> (defclass shift ()
>  ((i :initarg :i :reader shift-i)
>   (j :initarg :j :reader shift-j))
>  (:documentation "Couple of numbers"))
>
> (defmethod create-shift ((i integer) (j integer))
>  (make-instance 'shift :i i :j j))
>
> The problem is quite simple. I want to define a method "top-exists"
> that returns false if slot i is equal to zero, true otherwise.
>
> I've tried this as a special case, it works:
> (defmethod top-exists ((sh (eql (create-shift 0 0)))) nil)
> (top-exists (create-shift 0 0 )) ==> nil
>
> I know I can simply use this to solve my problems:
> (defmethod top-exists ((sh shift))
>  (> (shift-i sh) 0))
>
> But I would like it to be smarter, something like this:
> (defmethod top-exists ((sh (slot-i-is-equal-to 0))) nil)
>
> Is it possible?
>
> Thanks,
>
> Francesco
>
> PS I defined the method "create-shift" for i and j integer because I
> dont' know how to require the type of the slots of a class. In my case
> I want i and j to be positive integers or zero. Is there a way to do
> this in defclass? :)
> -- 
> Linux Registered User: #414858
>
> P Funking Band
> http://www.perugiafunkingband.it
> http://www.myspace.com/perugiafunkingband
> _______________________________________________
> Gardeners mailing list
> [email protected]
> http://www.lispniks.com/mailman/listinfo/gardeners

--
Gary Warren King, metabang.com
Cell: (413) 559 8738
Fax: (206) 338-4052
gwkkwg on Skype * garethsan on AIM * gwking on twitter





_______________________________________________
Gardeners mailing list
[email protected]
http://www.lispniks.com/mailman/listinfo/gardeners

Reply via email to