From: Jim Cheng
Subject: defmethod ver defunc ???
Date: 
Message-ID: <3988DEBA.BDE07CEB@yahoo.com>
What is the difference between defunc and defmethod in Lisp?

Thanks!

Jim

From: Thom Goodsell
Subject: Re: defmethod ver defunc ???
Date: 
Message-ID: <7vittiqxjo.fsf@shalott.cra.com>
Jim Cheng <·······@yahoo.com> writes:

> What is the difference between defunc and defmethod in Lisp?

Ok, I may get this wrong, but here's how I understand it.  'defunc'
defines a funciton; 'defmethod' defines a method.  How was that for
circular definition?

Methods, as opposed to functions, are used in OO programming (CLOS)
and can have multiple specializations.  For example, in your earlier
post, you had something like this:

  (defmethod draw-pid-curve ((circle pid-circle) stream color)
     ......)
  (defmethod draw-pid-curve ((arc pid-arc) stream color)
       ......)

This defines _one_ method which acts differently depending on the
object type of the first argument (whether it's a pid-circle or a
pid-arc).  FYI, all specializations of a method must have the same
number of parameters.

Functions are not specialized on their parameters, and you can
therefore only have one definition of a function.  If another function
is defined with the same name, it will replace the earlier definition.

I hope this helped.

Thom

-- 
Scientist				···@cra.com
Charles River Analytics		(617) 491-3474 x574
Cambridge, MA, USA		http://www.cra.com/
From: Jochen Schmidt
Subject: Re: defmethod ver defunc ???
Date: 
Message-ID: <398A49FC.992A307@gmx.de>
Thom Goodsell wrote:
> 
> Jim Cheng <·······@yahoo.com> writes:
> 
> > What is the difference between defunc and defmethod in Lisp?
> 
> Ok, I may get this wrong, but here's how I understand it.  'defunc'
> defines a funciton; 'defmethod' defines a method.  How was that for
> circular definition?
> 
> Methods, as opposed to functions, are used in OO programming (CLOS)
> and can have multiple specializations.  For example, in your earlier
> post, you had something like this:
> 
>   (defmethod draw-pid-curve ((circle pid-circle) stream color)
>      ......)
>   (defmethod draw-pid-curve ((arc pid-arc) stream color)
>        ......)
> 
> This defines _one_ method which acts differently depending on the
> object type of the first argument (whether it's a pid-circle or a
> pid-arc).  FYI, all specializations of a method must have the same
> number of parameters.

hm... I would say the lambda-lists of all methods of a generic-function
have to be congruent. But if you count optional and rest
parameter-definitions
as being each exactly one parameter then you're right.

sincerely Yours,
Jochen Schmidt <···@dataheaven.de>