[Openmcl-devel] Problems with call-next-method in 1.4-dev-r12912M-trunk (WindowsX8632)

R. Matthew Emerson rme at clozure.com
Mon Oct 5 19:38:14 PDT 2009


Hmm.  The spec says:

"When providing arguments to call-next-method, the following rule must  
be satisfied or an error of type error should be signaled: the ordered  
set of applicable methods for a changed set of arguments for call-next- 
method must be the same as the ordered set of applicable methods for  
the original arguments to the generic function. Optimizations of the  
error checking are possible, but they must not change the semantics of  
call-next-method."

http://www.lispworks.com/documentation/HyperSpec/Body/f_call_n.htm#call-next-method

I understand that to mean that the following has to be true:

(equal (compute-applicable-methods #'foo (list 'bar "baz"))
        (compute-applicable-methods #'foo (list 'bar 3)))

CCL> (compute-applicable-methods #'foo (list 'bar "baz"))
(#<STANDARD-METHOD FOO ((EQL BAR) STRING)>
  #<STANDARD-METHOD FOO ((EQL BAR) T)>)
CCL> (compute-applicable-methods #'foo (list 'bar 3))
(#<STANDARD-METHOD FOO ((EQL BAR) T)>)
CCL>

I wouldn't claim to be a language lawyer, but it does appear to me  
that CCL is correct to signal an error in this case.


On Oct 5, 2009, at 3:20 PM, Matthew Swank wrote:

> This looks like it should work ok:
>
> CL-USER> (defgeneric foo (bar baz))
> #<STANDARD-GENERIC-FUNCTION FOO #xA8F3C1E>
>
> CL-USER> (defmethod foo ((bar (eql 'bar)) (baz string))
> 	   (call-next-method bar (length baz)))
> #<STANDARD-METHOD FOO ((EQL BAR) STRING)>
>
> CL-USER> (defmethod foo ((bar (eql 'bar)) baz)
> 	   (cons baz baz))
> #<STANDARD-METHOD FOO ((EQL BAR) T)>
>
> CL-USER> (foo 'bar "baz")
>
> =>
> Applicable-methods changed in call-next-method.
> Should be: (#<STANDARD-METHOD FOO ((EQL BAR) STRING)>
>            #1=#<STANDARD-METHOD FOO (# T)>)
> Was: (#1#)
> Next-methods: (#1#)
>   [Condition of type SIMPLE-ERROR]
>
> Restarts:
> 0: [RETRY] Retry SLIME REPL evaluation request.
> 1: [ABORT] Return to SLIME's top level.
> 2: [ABORT-BREAK] Reset this thread
> 3: [ABORT] Kill this thread
>
> Backtrace:
>  0: ((:INTERNAL CCL::DO-IT CCL::%%CNM-WITH-ARGS-COMBINED-METHOD-DCODE)
> #(#<STANDARD-GENERIC-FUNCTION FOO #xA84C996> (#1=#<STANDARD-METHOD  
> FOO #>
> #2=#<#>) NIL NIL (#1# #2#)) (BAR 3))
>      Locals:
>        CCL::THING = #(#<STANDARD-GENERIC-FUNCTION FOO #xA84C996> ..))
>        CCL::ARGS = (BAR 3)
>        CCL::ARGS-LEN = 2
>        CCL::GF = #<STANDARD-GENERIC-FUNCTION FOO #xA84C996>
>        CCL::NUMREQ = 2
>        CCL::NEXT-METHODS = (#<STANDARD-METHOD FOO ((EQL BAR) T)>)
>        CCL::OLD-ARGS = 12108566
>        CCL::NEW-METHODS = (#<STANDARD-METHOD FOO ((EQL BAR) T)>)
>        CCL::OLD-METHODS = (#<STANDARD-METHOD FOO ((EQL BAR) STRING)>
> #<STANDARD-METHOD FOO (# T)>)
>        CCL::MAGIC = (#(#<STANDARD-GENERIC-FUNCTION FOO #xA84C996>  
> (#<#> #<#>)
> NIL NIL ..)))))
>  1: (CCL::%%CNM-WITH-ARGS-COMBINED-METHOD-DCODE #(#<STANDARD-GENERIC- 
> FUNCTION
> FOO #xA84C996> (#1=#<STANDARD-METHOD FOO #> #2=#<#>) NIL NIL (#1#  
> #2#)) (BAR 3)
> (#(#<STANDARD-GENERIC-FUNCTION FOO #xA84C996> ..
>      Locals:
>        CCL::THING = #(#<STANDARD-GENERIC-FUNCTION FOO #xA84C996> ..))
>        CCL::ARGS = (BAR 3)
>        CCL::MAGIC = (#(#<STANDARD-GENERIC-FUNCTION FOO #xA84C996>  
> (#<#> #<#>)
> NIL NIL ..)))))
>  2: (CCL::%CALL-NEXT-METHOD-WITH-ARGS (#(#<STANDARD-GENERIC-FUNCTION  
> FOO
> #xA84C996> (#1=#<#> #2=#<#>) NIL NIL (#1# #2#)) (#2#) . 12108566)  
> BAR 3)
>      Locals:
>        CCL::MAGIC = (#(#<STANDARD-GENERIC-FUNCTION FOO #xA84C996>  
> (#<#> #<#>)
> NIL NIL ..)))))
>        CCL::ARGS = (BAR 3)
>        CCL::METHODS = (#<STANDARD-METHOD FOO ((EQL BAR) T)>)
>        CCL::CNM-CM = #(#<STANDARD-GENERIC-FUNCTION FOO #xA84C996> ..))
>        CCL::THE-VECT = #(#<STANDARD-GENERIC-FUNCTION FOO  
> #xA84C996> ..))
>  3: (CCL::%%CNM-WITH-ARGS-COMBINED-METHOD-DCODE #(#<STANDARD-GENERIC- 
> FUNCTION
> FOO #xA84C996> (#1=#<STANDARD-METHOD FOO #> #2=#<#>) NIL NIL (#1#  
> #2#)) 12108566
> NIL)
>      Locals:
>        CCL::THING = #(#<STANDARD-GENERIC-FUNCTION FOO #xA84C996> ..))
>        CCL::ARGS = 12108566
>        CCL::MAGIC = NIL
>        CCL::METHODS = (#<STANDARD-METHOD FOO ((EQL BAR) STRING)>
> #<STANDARD-METHOD FOO (# T)>)
>        CCL::CAR-METHS = #<STANDARD-METHOD FOO ((EQL BAR) STRING)>
>        CCL::CELL-2 = ((#<STANDARD-METHOD FOO (# T)>) . 12108566)
>        CCL::MAGIC = (#(#<STANDARD-GENERIC-FUNCTION FOO #xA84C996>  
> (#<#> #<#>)
> NIL NIL ..)))))
>        #:G103106 = (#(#<STANDARD-GENERIC-FUNCTION FOO #xA84C996>  
> (#<#> #<#>)
> NIL NIL ..)))))
>        #:G103107 = #<METHOD-FUNCTION FOO ((EQL BAR) STRING)>
>        #:G103108 = 12108566
>  4: (NIL #<Unknown Arguments>)
>      [No Locals]
>  5: (NIL #<Unknown Arguments>)
>      [No Locals]
>  6: (CCL::CALL-CHECK-REGS FOO BAR "baz")
>
> ....
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel




More information about the Openmcl-devel mailing list