From: Jim Bushnell
Subject: defgeneric and then defun signals no error
Date: 
Message-ID: <9jn0c6$nfb$1@sloth.swcp.com>
In both LispWorks 4.1.20 and Allegro CL 5.0.1, the following is accepted
with no error being signaled:

(defmethod abc ((i integer)) i)
;; and then
(defun abc (i) i)

while an error is signaled for the reverse:

(defun bcd (i) i)
;; and then
(defmethod bcd ((i integer)) i)

This behavior is in agreement with the CL HyperSpec, which specifies an
error in the second case but not in the first. I wonder why X3J13 didn't
consider the first also as signaling an error. I can shoot myself in the
foot if I forget that I have already defined a generic function (and
methods) and then make an ordinary function with the same name. Perhaps Kent
Pitman or someone else remembers something about this?

Thanks, Jim Bushnell

From: Barry Margolin
Subject: Re: defgeneric and then defun signals no error
Date: 
Message-ID: <krD97.22$TO3.193@burlma1-snr2>
In article <············@sloth.swcp.com>,
Jim Bushnell <········@swcp.com> wrote:
>In both LispWorks 4.1.20 and Allegro CL 5.0.1, the following is accepted
>with no error being signaled:
>
>(defmethod abc ((i integer)) i)
>;; and then
>(defun abc (i) i)
>
>while an error is signaled for the reverse:
>
>(defun bcd (i) i)
>;; and then
>(defmethod bcd ((i integer)) i)
>
>This behavior is in agreement with the CL HyperSpec, which specifies an
>error in the second case but not in the first. I wonder why X3J13 didn't
>consider the first also as signaling an error. I can shoot myself in the
>foot if I forget that I have already defined a generic function (and
>methods) and then make an ordinary function with the same name. Perhaps Kent
>Pitman or someone else remembers something about this?

I think it was mainly for historical consistency.  We've always been able
to redefine a function using DEFUN, so we didn't remove that capability.
Generic functions, as a new feature being added to the language, didn't
need to retain compatibility.

Another reason was that there were some people who opined that if a
normal function is redefined as a generic function, the old definition
should be retained as the method when all the parameter specializers were T
(i.e. it would be the default method).  This was especially wished in the
case where the generic function is created implicitly using DEFMETHOD,
rather than with DEFGENERIC.  We decided not to do this, but it was easy to
predict that some users might intuitively expect that behavior (perhaps
they didn't check whether BCD was defined as a generic or normal
function).  So rather than silently throw away the existing definition, we
required an error be signalled.

-- 
Barry Margolin, ······@genuity.net
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
From: Kent M Pitman
Subject: Re: defgeneric and then defun signals no error
Date: 
Message-ID: <sfw4rrs6dhq.fsf@world.std.com>
Barry Margolin <······@genuity.net> writes:

> [signaling error when redefining function as generic but not vice versa]
>
> Another reason was that there were some people who opined that if a
> normal function is redefined as a generic function, the old definition
> should be retained as the method when all the parameter specializers were T
> (i.e. it would be the default method).  This was especially wished in the
> case where the generic function is created implicitly using DEFMETHOD,
> rather than with DEFGENERIC.  We decided not to do this, but it was easy to
> predict that some users might intuitively expect that behavior (perhaps
> they didn't check whether BCD was defined as a generic or normal
> function).  So rather than silently throw away the existing definition, we
> required an error be signalled.

This is the rationale I remember.