From: Lars Rune Nøstdal
Subject: :method-combination +
Date: 
Message-ID: <pan.2006.11.10.06.51.42.265113@gmail.com>
Ok, people at #lisp seem to be sleeping ATM so I'll post this here also:

(defgeneric priority (job)
  (:method-combination +))


(defclass ExpressJob ()
  ())

(defmethod priority + ((job ExpressJob))
  10)


(defclass StandardJob ()
  ())

(defmethod priority + ((job StandardJob))
  5)

;;;;;

(values (priority (make-instance 'ExpressJob))
        (priority (make-instance 'StandardJob)))
10
5


I must be misunderstanding this - shouldn't this return 15 and 15..?

-- 
Lars Rune Nøstdal
http://lars.nostdal.org/

From: Bill Atkins
Subject: Re: :method-combination +
Date: 
Message-ID: <m2irhnvkf8.fsf@weedle-24.dynamic.rpi.edu>
Lars Rune N�stdal <···········@gmail.com> writes:

> Ok, people at #lisp seem to be sleeping ATM so I'll post this here also:
>
> (defgeneric priority (job)
>   (:method-combination +))
>
>
> (defclass ExpressJob ()
>   ())
>
> (defmethod priority + ((job ExpressJob))
>   10)
>
>
> (defclass StandardJob ()
>   ())
>
> (defmethod priority + ((job StandardJob))
>   5)
>
> ;;;;;
>
> (values (priority (make-instance 'ExpressJob))
>         (priority (make-instance 'StandardJob)))
> 10
> 5
>
>
> I must be misunderstanding this - shouldn't this return 15 and 15..?

No.  ExpressJob is not a subclass of StandardJob, or vice-versa.
From: Lars Rune Nøstdal
Subject: Re: :method-combination +
Date: 
Message-ID: <pan.2006.11.10.07.27.29.938214@gmail.com>
On Fri, 10 Nov 2006 02:18:51 -0500, Bill Atkins wrote:

> Lars Rune Nøstdal <···········@gmail.com> writes:
> 
>> Ok, people at #lisp seem to be sleeping ATM so I'll post this here also:
>>
>> (defgeneric priority (job)
>>   (:method-combination +))
>>
>>
>> (defclass ExpressJob ()
>>   ())
>>
>> (defmethod priority + ((job ExpressJob))
>>   10)
>>
>>
>> (defclass StandardJob ()
>>   ())
>>
>> (defmethod priority + ((job StandardJob))
>>   5)
>>
>> ;;;;;
>>
>> (values (priority (make-instance 'ExpressJob))
>>         (priority (make-instance 'StandardJob)))
>> 10
>> 5
>>
>>
>> I must be misunderstanding this - shouldn't this return 15 and 15..?
> 
> No.  ExpressJob is not a subclass of StandardJob, or vice-versa.

Ouch - right. :}

-- 
Lars Rune Nøstdal
http://lars.nostdal.org/
From: Pascal Costanza
Subject: Re: :method-combination +
Date: 
Message-ID: <4rin54FrdjskU1@mid.individual.net>
Lars Rune Nøstdal wrote:
> Ok, people at #lisp seem to be sleeping ATM so I'll post this here also:
> 
> (defgeneric priority (job)
>   (:method-combination +))
> 
> 
> (defclass ExpressJob ()
>   ())
> 
> (defmethod priority + ((job ExpressJob))
>   10)
> 
> 
> (defclass StandardJob ()
>   ())
> 
> (defmethod priority + ((job StandardJob))
>   5)
> 
> ;;;;;
> 
> (values (priority (make-instance 'ExpressJob))
>         (priority (make-instance 'StandardJob)))
> 10
> 5
> 
> 
> I must be misunderstanding this - shouldn't this return 15 and 15..?

Method combinations don't change method applicability. They only change, 
well, method combination.


Pascal

-- 
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/