Re: Allegro and Sbcl disagree on no-primary-method behavior



> Edi Weitz wrote:
>> On Thu, 29 May 2008 15:21:10 +0200, Jim Newton <jimka@xxxxxxxxxxx> wrote:
>>
>>
>>> Does anyone know what the behavior should be if a generic function
>>> has an around method which does NOT call call-next-method, but there
>>> is no primary method?
>>>
>>> It seems that sbcl calls SB-PCL::NO-PRIMARY-METHOD which normally
>>> signals an error, but allegro calls the around method
>>>
>>> (defgeneric foo (x))
>>> (defmethod foo :around (x) 1)
>>> (foo 1)
>>>
>>> This returns 1 in allegro, and errors in sbcl. Any opinions about
>>> which is correct behavior?
>>
>>
>> 7.6.6.2:
>>
>> "In standard method combination, if there is an applicable method
>> but no applicable primary method, an error is signaled."
>>
>> Looks like AllegroCL is wrong. FWIW, LispWorks and ClozureCL also
>> signal an error here.
>>

Jim Newton wrote:
7.6.6.2 says that an error is signaled but it does not say WHEN
it is signaled. It clearly should not be signaled at definition
time, because you might define the around method before the primary
method. or am i missing something?

7.6.6.2 describes the standard method combination. Method combination is a well-defined phase of generic function invocation, which consists of (a) selecting the applicable methods, (b) combining them into an effective method, and (c) invoking the effective method. This means that the error is signaled on generic function invocation in step (b).

The error can be avoided by implementing one's own version of the standard method combination. See the examples section in the specification for define-method-combination. There, the 'standard method combination is redefined. Just remove the :required t option, and you won't get the error. (You are actually not allowed to redefine the 'standard method combination, so you have to choose a different name for your 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/
.



Relevant Pages