From: ············@gmail.com
Subject: defmethod vs defun
Date: 
Message-ID: <5948c58f-aa1b-408e-81b8-c3d607d534b1@c65g2000hsa.googlegroups.com>
hello,

What's the interest of defmethod vs defun when using CLOS without
polymorphism ?

-Nicolas

From: Ken Tilton
Subject: Re: defmethod vs defun
Date: 
Message-ID: <48340a0e$0$25045$607ed4bc@cv.net>
············@gmail.com wrote:
> hello,
> 
> What's the interest of defmethod vs defun when using CLOS without
> polymorphism ?

None. Use defun if defun works. It is faster (barely) but more 
importantly offers a bit of self-documentation (that the function is not 
type-sensitive).

kt

-- 
http://smuglispweeny.blogspot.com/
http://www.theoryyalgebra.com/
ECLM rant: 
http://video.google.com/videoplay?docid=-1331906677993764413&hl=en
ECLM talk: 
http://video.google.com/videoplay?docid=-9173722505157942928&q=&hl=en
From: Pascal Costanza
Subject: Re: defmethod vs defun
Date: 
Message-ID: <69jg8cF33ou6hU1@mid.individual.net>
Ken Tilton wrote:
> 
> 
> ············@gmail.com wrote:
>> hello,
>>
>> What's the interest of defmethod vs defun when using CLOS without
>> polymorphism ?
> 
> None. Use defun if defun works. It is faster (barely) but more 
> importantly offers a bit of self-documentation (that the function is not 
> type-sensitive).

Don't be silly. Almost every other function is type-sensitive.


Pascal

-- 
1st European Lisp Symposium (ELS'08)
http://prog.vub.ac.be/~pcostanza/els08/

My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
From: Ken Tilton
Subject: Re: defmethod vs defun
Date: 
Message-ID: <483496db$0$15162$607ed4bc@cv.net>
Pascal Costanza wrote:
> Ken Tilton wrote:
> 
>>
>>
>> ············@gmail.com wrote:
>>
>>> hello,
>>>
>>> What's the interest of defmethod vs defun when using CLOS without
>>> polymorphism ?
>>
>>
>> None. Use defun if defun works. It is faster (barely) but more 
>> importantly offers a bit of self-documentation (that the function is 
>> not type-sensitive).
> 
> 
> Don't be silly. 

[Edi, are you /sure/ it's my fault? I thought so, too, now I don't know.]

So what application did you settle on to evaluate Cells? Tower of Hanoi?

kenny

-- 
http://smuglispweeny.blogspot.com/
http://www.theoryyalgebra.com/
ECLM rant: 
http://video.google.com/videoplay?docid=-1331906677993764413&hl=en
ECLM talk: 
http://video.google.com/videoplay?docid=-9173722505157942928&q=&hl=en
From: Pascal Costanza
Subject: Re: defmethod vs defun
Date: 
Message-ID: <69jkmeF2v9lusU1@mid.individual.net>
Ken Tilton wrote:
> 
> 
> Pascal Costanza wrote:
>> Ken Tilton wrote:
>>
>>>
>>>
>>> ············@gmail.com wrote:
>>>
>>>> hello,
>>>>
>>>> What's the interest of defmethod vs defun when using CLOS without
>>>> polymorphism ?
>>>
>>>
>>> None. Use defun if defun works. It is faster (barely) but more 
>>> importantly offers a bit of self-documentation (that the function is 
>>> not type-sensitive).
>>
>>
>> Don't be silly. 
> 
> [Edi, are you /sure/ it's my fault? I thought so, too, now I don't know.]
> 
> So what application did you settle on to evaluate Cells? Tower of Hanoi?

Who said I was evaluating Cells?


Pascal

-- 
1st European Lisp Symposium (ELS'08)
http://prog.vub.ac.be/~pcostanza/els08/

My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
From: Ken Tilton
Subject: Re: defmethod vs defun
Date: 
Message-ID: <4834b1c7$0$25058$607ed4bc@cv.net>
Pascal Costanza wrote:
> Ken Tilton wrote:
> 
>>
>>
>> Pascal Costanza wrote:
>>
>>> Ken Tilton wrote:
>>>
>>>>
>>>>
>>>> ············@gmail.com wrote:
>>>>
>>>>> hello,
>>>>>
>>>>> What's the interest of defmethod vs defun when using CLOS without
>>>>> polymorphism ?
>>>>
>>>>
>>>>
>>>> None. Use defun if defun works. It is faster (barely) but more 
>>>> importantly offers a bit of self-documentation (that the function is 
>>>> not type-sensitive).
>>>
>>>
>>>
>>> Don't be silly. 
>>
>>
>> [Edi, are you /sure/ it's my fault? I thought so, too, now I don't know.]
>>
>> So what application did you settle on to evaluate Cells? Tower of Hanoi?
> 
> 
> Who said I was evaluating Cells?
> 

Well if you are just trying to fill up your hard drive to get your 
school to buy a bigger system...

> Ken Tilton wrote:
> 
>>
>> As PG said, when good programmers like something, don't argue, download.
> 
> 
> Yes, I am doing that. :-D
> 
> 
> Pascal

...there are some multimedia web sites I can point you to, and they 
definitely are more interesting than Cells.

hth, kenny

-- 
http://smuglispweeny.blogspot.com/
http://www.theoryyalgebra.com/
ECLM rant: 
http://video.google.com/videoplay?docid=-1331906677993764413&hl=en
ECLM talk: 
http://video.google.com/videoplay?docid=-9173722505157942928&q=&hl=en
From: Pascal Costanza
Subject: Re: defmethod vs defun
Date: 
Message-ID: <69kfehF3363oaU1@mid.individual.net>
Ken Tilton wrote:
> 
> 
> Pascal Costanza wrote:
>> Ken Tilton wrote:
>>
>>>
>>>
>>> Pascal Costanza wrote:
>>>
>>>> Ken Tilton wrote:
>>>>
>>>>>
>>>>>
>>>>> ············@gmail.com wrote:
>>>>>
>>>>>> hello,
>>>>>>
>>>>>> What's the interest of defmethod vs defun when using CLOS without
>>>>>> polymorphism ?
>>>>>
>>>>>
>>>>>
>>>>> None. Use defun if defun works. It is faster (barely) but more 
>>>>> importantly offers a bit of self-documentation (that the function 
>>>>> is not type-sensitive).
>>>>
>>>>
>>>>
>>>> Don't be silly. 
>>>
>>>
>>> [Edi, are you /sure/ it's my fault? I thought so, too, now I don't 
>>> know.]
>>>
>>> So what application did you settle on to evaluate Cells? Tower of Hanoi?
>>
>>
>> Who said I was evaluating Cells?
>>
> 
> Well if you are just trying to fill up your hard drive to get your 
> school to buy a bigger system...
> 
>> Ken Tilton wrote:
>>
>>>
>>> As PG said, when good programmers like something, don't argue, download.
>>
>> Yes, I am doing that. :-D
>>
>> Pascal
> 
> ...there are some multimedia web sites I can point you to, and they 
> definitely are more interesting than Cells.

I thought the focus was on what _good_ programmers like. :-P

No, I didn't download Cells again after that exchange. I did it before, 
and I told you what I think about it. Since you can't deal with 
criticism, I am not going into further details...


Pascal

-- 
1st European Lisp Symposium (ELS'08)
http://prog.vub.ac.be/~pcostanza/els08/

My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
From: Ken Tilton
Subject: Re: defmethod vs defun
Date: 
Message-ID: <483518e2$0$11618$607ed4bc@cv.net>
Pascal Costanza wrote:
> Ken Tilton wrote:
> 
>>
>>
>> Pascal Costanza wrote:
>>
>>> Ken Tilton wrote:
>>>
>>>>
>>>>
>>>> Pascal Costanza wrote:
>>>>
>>>>> Ken Tilton wrote:
>>>>>
>>>>>>
>>>>>>
>>>>>> ············@gmail.com wrote:
>>>>>>
>>>>>>> hello,
>>>>>>>
>>>>>>> What's the interest of defmethod vs defun when using CLOS without
>>>>>>> polymorphism ?
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> None. Use defun if defun works. It is faster (barely) but more 
>>>>>> importantly offers a bit of self-documentation (that the function 
>>>>>> is not type-sensitive).
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Don't be silly. 
>>>>
>>>>
>>>>
>>>> [Edi, are you /sure/ it's my fault? I thought so, too, now I don't 
>>>> know.]
>>>>
>>>> So what application did you settle on to evaluate Cells? Tower of 
>>>> Hanoi?
>>>
>>>
>>>
>>> Who said I was evaluating Cells?
>>>
>>
>> Well if you are just trying to fill up your hard drive to get your 
>> school to buy a bigger system...
>>
>>> Ken Tilton wrote:
>>>
>>>>
>>>> As PG said, when good programmers like something, don't argue, 
>>>> download.
>>>
>>>
>>> Yes, I am doing that. :-D
>>>
>>> Pascal
>>
>>
>> ...there are some multimedia web sites I can point you to, and they 
>> definitely are more interesting than Cells.
> 
> 
> I thought the focus was on what _good_ programmers like. :-P

I was wondering why that fat pitch did not belted into the bay the first 
time. :)

> 
> No, I didn't download Cells again after that exchange.

Oh. Fascinating.

> I did it before, 
> and I told you what I think about it.

No, you told someone else it was so bad you would not trust it and I 
invited you to expand on your calumny. You demurred.

> Since you can't deal with 
> criticism, 

We'll know when you produce some, so far all we have is "so bad I would 
not trust it". That is name-calling. It will be criticism when you back 
it up.

I am actually quite curious to see what you come up with. I might agree. 
I guess I already agree that the code is a bit like an old city, with 
the new patched in over the old.

>...I am not going into further details...

Go ahead, I might agree as per the above. Or maybe you are just talking 
about all the debugging and sanity check code left in place for future 
firefights. I demonstrated one forty line wadge being reduced to eight, 
that was fun. Tempting to do that to the whole package some day. Does 
anyone else have  a library like that with all sorts of diagnostic stuff 
left in place for future use? Code that looks like that scene from 
Brazil where Robert be Niro comes to work on the air conditioning? I 
digress.

Or maybe you can help with the users-used tracking mechanism. I hate 
that bit. The good news here is that it is win-win all around, either 
Cells gets better or, as when Philip Eby did a review of my integrity 
algorithm (but not the code) and concluded it was sound, Cells gets 
validated.

We will also have some great Lisp style discussions for the noobs and 
even veterans. Of course if you were just blowing smoke... hey, maybe 
you can get all the yobbos together to help you, they'd love that.

kenny

-- 
http://smuglispweeny.blogspot.com/
http://www.theoryyalgebra.com/
ECLM rant: 
http://video.google.com/videoplay?docid=-1331906677993764413&hl=en
ECLM talk: 
http://video.google.com/videoplay?docid=-9173722505157942928&q=&hl=en
From: Pascal Costanza
Subject: Re: defmethod vs defun
Date: 
Message-ID: <69o9opF310qa2U1@mid.individual.net>
Ken Tilton wrote:
> 
> 
> Pascal Costanza wrote:
>> I did it before, and I told you what I think about it.
> 
> No, you told someone else it was so bad you would not trust it 

That _is_ what I think about it.

> and I 
> invited you to expand on your calumny. You demurred.

Yep, and I told you why.

>> Since you can't deal with criticism, 
> 
> We'll know when you produce some, so far all we have is "so bad I would 
> not trust it". That is name-calling. It will be criticism when you back 
> it up.

I didn't claim that I gave a criticism of your code, I claim that if I 
gave it, you wouldn't be able to deal with it.

>  Of course if you were just blowing smoke... hey, maybe
> you can get all the yobbos together to help you, they'd love that.

I don't know how to parse that as an invitation.


Pascal

-- 
1st European Lisp Symposium (ELS'08)
http://prog.vub.ac.be/~pcostanza/els08/

My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
From: Ken Tilton
Subject: Fred Brooks on Cells! [was Re: defmethod vs defun]
Date: 
Message-ID: <483706ce$0$25051$607ed4bc@cv.net>
Pascal Costanza wrote:
> Ken Tilton wrote:
> 
>>
>>
>> Pascal Costanza wrote:
>>
>>> I did it before, and I told you what I think about it.
>>
>>
>> No, you told someone else it was so bad you would not trust it 
> 
> 
> That _is_ what I think about it.
> 
>> and I invited you to expand on your calumny. You demurred.
> 
> 
> Yep, and I told you why.


Ok, now even I am bored.

Anyway, the anniversary edition of Brooks's "The Mythical Man-Month" 
ended up in plain view -- I quote it often and my indexing scheme for 
stuff involves "plain sight" -- while an exchange with the legendary Jay 
Sulzberger over the meaning of "is" led to him linking me to a quantum 
dataflow diagram of his <inject oceanside handwaving> and I said, Why 
not? and dashed off a note to Dr. Brooks asking if dataflow had entered 
the lists for the Yes Silver Bullet Prize. I guess he has not heard of 
me because he answered: turns out he worked on the IBM Harvest computer, 
way back when, a dataflow machine. Shazzam! But Brooks reports "I did 
not consider [dataflow programming] to be a serious programming contender."

Pascal! Yer right!!

:)

kenny

ps.

>>  Of course if you were just blowing smoke... hey, maybe
>> you can get all the yobbos together to help you, they'd love that.
> 
> 
> I don't know how to parse that as an invitation.

The one I remember from the archives of #lisp IRC was something subtle 
like "Kenny is being a jerk about X on c.l.l, let's go get him.", to 
which someone replied in marvelous self-reference:

       "Let's make him think there is a conspiracy."

You can't make that stuff up (unless they did).

:) k


-- 
http://smuglispweeny.blogspot.com/
http://www.theoryyalgebra.com/
ECLM rant: 
http://video.google.com/videoplay?docid=-1331906677993764413&hl=en
ECLM talk: 
http://video.google.com/videoplay?docid=-9173722505157942928&q=&hl=en
From: Ken Tilton
Subject: Re: Fred Brooks on Cells! [was Re: defmethod vs defun]
Date: 
Message-ID: <483710eb$0$25025$607ed4bc@cv.net>
Ken Tilton wrote:
> 
> 
> Pascal Costanza wrote:
> 
>> Ken Tilton wrote:
>>
>>>
>>>
>>> Pascal Costanza wrote:
>>>
>>>> I did it before, and I told you what I think about it.
>>>
>>>
>>>
>>> No, you told someone else it was so bad you would not trust it 
>>
>>
>>
>> That _is_ what I think about it.
>>
>>> and I invited you to expand on your calumny. You demurred.
>>
>>
>>
>> Yep, and I told you why.
> 
> 
> 
> Ok, now even I am bored.
> 
> Anyway, the anniversary edition of Brooks's "The Mythical Man-Month" 
> ended up in plain view -- I quote it often and my indexing scheme for 
> stuff involves "plain sight" -- while an exchange with the legendary Jay 
> Sulzberger over the meaning of "is" led to him linking me to a quantum 
> dataflow diagram of his <inject oceanside handwaving>

er, that reads wrong, the handwaving is mine trying to describe Jay's 
erudite quantum stuff.

kt

  and I said, Why
> not? and dashed off a note to Dr. Brooks asking if dataflow had entered 
> the lists for the Yes Silver Bullet Prize. I guess he has not heard of 
> me because he answered: turns out he worked on the IBM Harvest computer, 
> way back when, a dataflow machine. Shazzam! But Brooks reports "I did 
> not consider [dataflow programming] to be a serious programming contender."
> 
> Pascal! Yer right!!
> 
> :)
> 
> kenny
> 
> ps.
> 
>>>  Of course if you were just blowing smoke... hey, maybe
>>> you can get all the yobbos together to help you, they'd love that.
>>
>>
>>
>> I don't know how to parse that as an invitation.
> 
> 
> The one I remember from the archives of #lisp IRC was something subtle 
> like "Kenny is being a jerk about X on c.l.l, let's go get him.", to 
> which someone replied in marvelous self-reference:
> 
>       "Let's make him think there is a conspiracy."
> 
> You can't make that stuff up (unless they did).
> 
> :) k
> 
> 

-- 
http://smuglispweeny.blogspot.com/
http://www.theoryyalgebra.com/
ECLM rant: 
http://video.google.com/videoplay?docid=-1331906677993764413&hl=en
ECLM talk: 
http://video.google.com/videoplay?docid=-9173722505157942928&q=&hl=en
From: Pascal Costanza
Subject: Re: Fred Brooks on Cells! [was Re: defmethod vs defun]
Date: 
Message-ID: <69otsgF327v2cU1@mid.individual.net>
Ken Tilton wrote:
> 
> :) k
> 

It's good to know you're having fun.


Pascal

-- 
1st European Lisp Symposium (ELS'08)
http://prog.vub.ac.be/~pcostanza/els08/

My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
From: Scott
Subject: Re: defmethod vs defun
Date: 
Message-ID: <badb8a4b-2ba3-4776-87ff-6f15e3d2af73@y18g2000pre.googlegroups.com>
Pascal Costanza <····@p-cos.net> wrote:
> Ken Tilton wrote:
>
> > Pascal Costanza wrote:
> >> I did it before, and I told you what I think about it.
>
> > No, you told someone else it was so bad you would not trust it
>
> That _is_ what I think about it.
>
> > and I
> > invited you to expand on your calumny. You demurred.
>
> Yep, and I told you why.
>

I can handle criticism of Kenny's Cells stuff.  Really, I'm not
sensitive about that at all, and I don't care too much about Kenny's
feelings either.  Perhaps you'd share your critique for the benefit of
the rest of us?  Pretty please?


I've never given Cells a fair shake because I haven't given Common
Lisp a fair shake.  I would play with Cells if I could find a Scheme
friendly version...  I checked out the PyCells page, but decided it
wasn't worth learning some voodoo installer.  Clever stuff annoys me.
What's wrong with tarballs?
From: Pascal Costanza
Subject: Re: defmethod vs defun
Date: 
Message-ID: <69ou02F327v2cU2@mid.individual.net>
Scott wrote:
> Pascal Costanza <····@p-cos.net> wrote:
>> Ken Tilton wrote:
>>
>>> Pascal Costanza wrote:
>>>> I did it before, and I told you what I think about it.
>>> No, you told someone else it was so bad you would not trust it
>> That _is_ what I think about it.
>>
>>> and I
>>> invited you to expand on your calumny. You demurred.
>> Yep, and I told you why.
>>
> 
> I can handle criticism of Kenny's Cells stuff.  Really, I'm not
> sensitive about that at all, and I don't care too much about Kenny's
> feelings either.  Perhaps you'd share your critique for the benefit of
> the rest of us?  Pretty please?

If you know a way how to stop Kenny participating in such a 
"discussion." ;-)

> I've never given Cells a fair shake because I haven't given Common
> Lisp a fair shake.  I would play with Cells if I could find a Scheme
> friendly version...  I checked out the PyCells page, but decided it
> wasn't worth learning some voodoo installer.  Clever stuff annoys me.
> What's wrong with tarballs?

...I think you're already getting a good idea. ;)

I hear that FrTime is a pretty good illustration of dataflow concepts in 
the Scheme world. The concepts doesn't need "Cells" as part of its name, 
you know...


Pascal

-- 
1st European Lisp Symposium (ELS'08)
http://prog.vub.ac.be/~pcostanza/els08/

My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
From: Ken Tilton
Subject: Re: defmethod vs defun
Date: 
Message-ID: <48374cee$0$25058$607ed4bc@cv.net>
Pascal Costanza wrote:
> Scott wrote:
> 
>> Pascal Costanza <····@p-cos.net> wrote:
>>
>>> Ken Tilton wrote:
>>>
>>>> Pascal Costanza wrote:
>>>>
>>>>> I did it before, and I told you what I think about it.
>>>>
>>>> No, you told someone else it was so bad you would not trust it
>>>
>>> That _is_ what I think about it.
>>>
>>>> and I
>>>> invited you to expand on your calumny. You demurred.
>>>
>>> Yep, and I told you why.
>>>
>>
>> I can handle criticism of Kenny's Cells stuff.  Really, I'm not
>> sensitive about that at all, and I don't care too much about Kenny's
>> feelings either.  Perhaps you'd share your critique for the benefit of
>> the rest of us?  Pretty please?
> 
> 
> If you know a way how to stop Kenny participating in such a 
> "discussion." ;-)

I would agree to those conditions. Many coaches ban parents from 
practice sessions. Something like that.

> 
>> I've never given Cells a fair shake because I haven't given Common
>> Lisp a fair shake.  I would play with Cells if I could find a Scheme
>> friendly version...  I checked out the PyCells page, but decided it
>> wasn't worth learning some voodoo installer.  Clever stuff annoys me.
>> What's wrong with tarballs?
> 
> 
> ...I think you're already getting a good idea. ;)
> 
> I hear that FrTime is a pretty good illustration of dataflow concepts in 
> the Scheme world. The concepts doesn't need "Cells" as part of its name, 
> you know...

Yep, but don't you find "lifting" to be a horrific requirement?

Scott, it seems to me the devil is in the details. C++ Adam requires a 
preprocessing step, COSI (not public) works only at the class level, 
FrTime requires any function to be involved in the dataflow game to be 
"lifted", and constraints? Run for your life!

Garnet's KR was programmer-friendly, I think. OpenLaszlo -- hey, if you 
are a web guy try that, I /think/ is is programmer friendly.

But PC is right, and I prove it every time I do something like 
TripleCells or JCells or Cells++ or ArcCells /from scratch/ in a day or 
two -- I have never actually ported Cells, more fun to reinvent. Shucks, 
you can roll Cells Lite yourself in a weekend in Scheme. I did it over 
the keyboard once at an infamous talk to a den of FSFers in the back of 
a Buddhist shop in the East Village, the best being when Mr. Sulzberger 
who was not expecting me did a little song and dance as he downloaded 
and installed SBCL before the third chorus.

hth,kt

-- 
http://smuglispweeny.blogspot.com/
http://www.theoryyalgebra.com/
ECLM rant: 
http://video.google.com/videoplay?docid=-1331906677993764413&hl=en
ECLM talk: 
http://video.google.com/videoplay?docid=-9173722505157942928&q=&hl=en
From: Pascal Costanza
Subject: Re: defmethod vs defun
Date: 
Message-ID: <69pq2mF32890oU1@mid.individual.net>
Ken Tilton wrote:
> 
> 
> Pascal Costanza wrote:
>> Scott wrote:
>>
>>> Pascal Costanza <····@p-cos.net> wrote:
>>>
>>>> Ken Tilton wrote:
>>>>
>>>>> Pascal Costanza wrote:
>>>>>
>>>>>> I did it before, and I told you what I think about it.
>>>>>
>>>>> No, you told someone else it was so bad you would not trust it
>>>>
>>>> That _is_ what I think about it.
>>>>
>>>>> and I
>>>>> invited you to expand on your calumny. You demurred.
>>>>
>>>> Yep, and I told you why.
>>>>
>>>
>>> I can handle criticism of Kenny's Cells stuff.  Really, I'm not
>>> sensitive about that at all, and I don't care too much about Kenny's
>>> feelings either.  Perhaps you'd share your critique for the benefit of
>>> the rest of us?  Pretty please?
>>
>>
>> If you know a way how to stop Kenny participating in such a 
>> "discussion." ;-)
> 
> I would agree to those conditions. Many coaches ban parents from 
> practice sessions. Something like that.

Nice try.


Pascal

-- 
1st European Lisp Symposium (ELS'08)
http://prog.vub.ac.be/~pcostanza/els08/

My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
From: Pascal J. Bourguignon
Subject: Re: defmethod vs defun
Date: 
Message-ID: <7czlqjrk97.fsf@pbourguignon.anevia.com>
············@gmail.com writes:
> What's the interest of defmethod vs defun when using CLOS without
> polymorphism ?

Perhaps some day you will use polymorphism?

Once you defun a symbol, it cannot become easily a generic function.
So if you plan to add some other methods later, possibly on some
subclasses you'll define later, it may be worthwhile to define a
methode right away.


Another advantage of methods over normal defun is that you have an
automatic type cheking.

(defmethod fact ((n integer))
  (if (< n 1) 1 (* n (fact (1- n)))))

(fact 32.42)
#1=#<STANDARD-METHOD (#2=#<BUILT-IN-CLASS INTEGER>)>
C/USER[33]> 
*** - NO-APPLICABLE-METHOD: When calling #<STANDARD-GENERIC-FUNCTION FACT> with arguments (32.42), no method is applicable.

So even when you don't have CLOS objects, it may be interesting to
define a method rather than a mere function, where you'd have to call
check-type or typecase yourself.

-- 
__Pascal Bourguignon__
From: Pascal Costanza
Subject: Re: defmethod vs defun
Date: 
Message-ID: <69jgp3F32upkhU1@mid.individual.net>
············@gmail.com wrote:
> hello,
> 
> What's the interest of defmethod vs defun when using CLOS without
> polymorphism ?

Generic functions are good for having separate definitions for the 
different types of arguments a function can deal with. However, that's 
actually quite easy to achieve in regular functions as well, by using 
cond, case, typecase, if, etc.

On top of that, generic functions provide a way to textually separate 
those definitions and, for example, provide them in different source 
files. This especially means that they can also be extended in user code 
by defining new methods on such generic functions that work on 
user-defined types. So it's best to use generic functions when you want 
to signal that they are open for specialization by user code.

However, extensibility by user code doesn't come for free. In general, 
you don't achieve a lot by blindly turning functions into generic 
functions without a careful design how users can extend them. You rather 
have to come up with good protocols and good ways how different generic 
functions interact with each other. Such a design should also be 
documented so that users can understand how method definitions affect 
the overall behavior of a system.

Nevertheless, it can sometimes add clarity to your code to use generic 
functions even when you don't want to provide them as hooks to the 
outside world. There is no real problem doing so from an efficiency 
point of view, because CLOS implementations are good at optimizing them. 
Since this depends a good deal on taste and personal programming style 
when to do that, it's hard to give general rules of thumb here. Just 
experiment with different ways of expressing things, and you will see 
what works and doesn't work for you.


Pascal

-- 
1st European Lisp Symposium (ELS'08)
http://prog.vub.ac.be/~pcostanza/els08/

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