From: Joel Reymont
Subject: Catch-all eql specializer
Date: 
Message-ID: <1109273089.905231.268280@z14g2000cwz.googlegroups.com>
Folks,

If I specialize a CLOS method on standard-object than this method will
be called when no other more specialized methods can be found. Is there
a way to do the same for EQL specializers?

    Thanks, Joel

From: Joel Reymont
Subject: Re: Catch-all eql specializer
Date: 
Message-ID: <1109273812.859722.211270@g14g2000cwa.googlegroups.com>
Hey, I'm the first to answer! :-)

(defclass foo () ())

;; eql specializer

(defmethod bar ((self foo) (x (eql 1))) 1)

;; "catch-all" specializer 

(defmethod baz ((self foo) x) 'any)
From: Frode Vatvedt Fjeld
Subject: Re: Catch-all eql specializer
Date: 
Message-ID: <2hk6oxn3pf.fsf@vserver.cs.uit.no>
"Joel Reymont" <······@gmail.com> writes:

> If I specialize a CLOS method on standard-object than this method
> will be called when no other more specialized methods can be found.

This is true in the same sense that it's true that any specialization
will be effective when no other more specialized specialization
exists. Normally, "t" is used as the default or nothing-in-particular
specializer. While it's not unthinkable, I believe it's very rare that
one would need to specialize on standard-object in normal application
code (i.e. stuff outside CLOS/MOP internals or -related hacks).

> Is there a way to do the same for EQL specializers?

This question doesn't make much sense. Are you thinking of something
like "(eql *)" that matches every object? That is of course precisely
the t class (and specializer).

-- 
Frode Vatvedt Fjeld
From: Joel Reymont
Subject: Re: Catch-all eql specializer
Date: 
Message-ID: <1109276359.023880.131280@l41g2000cwc.googlegroups.com>
Yes, I was thinking about the t and (eql *). As for making sense...
Imagine a message router where if no specific route exists for an event
it goes into the general funnel. That funnel is what I was looking for.

I'm writing a poker game where different types of betting limits might
exist. There are also a number of stages like pre-flop, flop, turn,
river.

With fixed limit there are two numbers, high and low. People can only
bet or raise the low of the limit during the pre-flop and flop stages
and the high of the limit during turn and river.  With pot limit it's
one formula for all stages.

I define fixed-limit and pot-limit classes and bet-size methods like
this:

(defmethod bet-size ((self fixed-limit)
		     (game game)
		     (player player)
		     (stage (eql 'pre-flop)))
  (values (low self) (low self)))

Another method specializing on 'flop would also return low/low and
methods specializing on 'turn and 'river would return high/high. For
pot limit it's just one catch-all method that looks like this:

(defmethod bet-size ((self pot-limit)
		     (game game)
		     (player player)
                   stage)
(declare (ignore stage))
...
)