cormanlisp icon indicating copy to clipboard operation
cormanlisp copied to clipboard

Error when trying to create STANDARD-METHOD instances.

Open j3pic opened this issue 6 years ago • 2 comments

Corman 3.1.2:

(make-instance 'standard-method :lambda-list '(foo)
               :function #'(lambda (foo) foo))
;;; An error of type SIMPLE-ERROR was detected in function STD-SLOT-VALUE:
;;; Error: The slot COMMON-LISP::BODY is unbound in the object #<;;; An error of type SIMPLE-ERROR was detected in function STD-SLOT-VALUE:
;;; Error: The slot COMMON-LISP::EFFECTIVE-SLOTS is missing from the class #<Standard-Class BUILT-IN-CLASS #x72CB850>.
;;; Entering Corman Lisp debug loop. 
;;; Use :C followed by an option to exit. Type :HELP for help.
;;; Restart options:
;;; 1   Abort to top level.

SBCL:

CL-USER> (make-instance 'standard-method :lambda-list '(foo)
               :function #'(lambda (foo) foo))
#<STANDARD-METHOD () {1004610F23}>

j3pic avatar Apr 21 '19 11:04 j3pic

For what it's worth, it doesn't work in CLISP in Windows when I tried it there. See further comments below Nigel viz. [1]> (make-instance 'standard-method :lambda-list '(foo) :function #'(lambda (foo) foo))

*** - (INITIALIZE-INSTANCE STANDARD-METHOD): Missing :SPECIALIZERS argument. The following restarts are available: ABORT :R1 Abort main loop

Full session:

i i i i i i i ooooo o ooooooo ooooo ooooo I I I I I I I 8 8 8 8 8 o 8 8 I \ +' / I 8 8 8 8 8 8 \ -+-' / 8 8 8 ooooo 8oooo `-|-' 8 8 8 8 8 | 8 o 8 8 o 8 8 ------+------ ooooo 8oooooo ooo8ooo ooooo 8

Welcome to GNU CLISP 2.48 (2009-07-28) http://clisp.cons.org/

Copyright (c) Bruno Haible, Michael Stoll 1992, 1993 Copyright (c) Bruno Haible, Marcus Daniels 1994-1997 Copyright (c) Bruno Haible, Pierpaolo Bernardi, Sam Steingold 1998 Copyright (c) Bruno Haible, Sam Steingold 1999-2000 Copyright (c) Sam Steingold, Bruno Haible 2001-2009

Type :h and hit Enter for context help.

[1]> (make-instance 'standard-method :lambda-list '(foo) :function #'(lambda (foo) foo))

*** - (INITIALIZE-INSTANCE STANDARD-METHOD): Missing :SPECIALIZERS argument. The following restarts are available: ABORT :R1 Abort main loop Break 1 [2]>

Regarding how SBCL is handling specializers we have

CL-USER> (setf return (make-instance 'standard-method :lambda-list '(foo) :function #'(lambda (foo) foo))) #<STANDARD-METHOD () {1003809DD3}> CL-USER> (describe return) #<STANDARD-METHOD () {1003809DD3}> [standard-object]

Slots with :INSTANCE allocation: SOURCE = NIL PLIST = NIL %GENERIC-FUNCTION = NIL QUALIFIERS = NIL SPECIALIZERS = NIL LAMBDA-LIST = (FOO) %FUNCTION = #<FUNCTION (LAMBDA (FOO)) {227EBC6B}> %DOCUMENTATION = NIL SIMPLE-NEXT-METHOD-CALL = NIL ; No value CL-USER> This allowing SPECIALIZERS to be nil given the LAMBDA-LIST seems against "The :specializers argument is a list of the specializer metaobjects for the method. An error is signaled if this value is not a proper list, or if the length of the list differs from the number of required arguments in the :lambda-list argument, or if any element of the list is not a specializer metaobject. If this value is not supplied, an error is signaled." at http://metamodular.com/CLOS-MOP/initialization-of-method-metaobjects.html But I don't know enough about CLOS to remark further re SBCL behavior but maybe this is better: CL-USER> (setf return (make-instance 'standard-method :function #'(lambda (foo) foo) :lambda-list '(foo) :specializers (list (find-class 'standard-object)))) #<STANDARD-METHOD (#<STANDARD-CLASS COMMON-LISP:STANDARD-OBJECT>) {1003A03E53}> CL-USER> (describe return) #<STANDARD-METHOD (#<STANDARD-CLASS COMMON-LISP:STANDARD-OBJECT>) {100.. [standard-object]

Slots with :INSTANCE allocation: SOURCE = NIL PLIST = NIL %GENERIC-FUNCTION = NIL QUALIFIERS = NIL SPECIALIZERS = (#<STANDARD-CLASS COMMON-LISP:STANDARD-OBJECT>) LAMBDA-LIST = (FOO) %FUNCTION = #<FUNCTION (LAMBDA (FOO)) {227EBC6B}> %DOCUMENTATION = NIL SIMPLE-NEXT-METHOD-CALL = NIL ; No value CL-USER>

It makes CLISP happy viz. [1]> (make-instance 'standard-method :function #'(lambda (foo) foo) :lambda-list '(foo))

*** - (INITIALIZE-INSTANCE STANDARD-METHOD): Missing :SPECIALIZERS argument. The following restarts are available: ABORT :R1 Abort main loop Break 1 [2]> :R1 [3]> (make-instance 'standard-method :function #'(lambda (foo) foo) :lambda-list '(foo) :specializers (list (find-class 'standard-object))) #<STANDARD-METHOD (#<STANDARD-CLASS STANDARD-OBJECT>)> [4]> But still fails on Corman Lisp viz (make-instance 'standard-method :lambda-list '(foo) :function #'(lambda (foo) foo) :specializers (list (find-class 'standard-object))) ;;; An error of type SIMPLE-ERROR was detected in function STD-SLOT-VALUE: ;;; Error: The slot COMMON-LISP::BODY is unbound in the object #<;;; An error of type SIMPLE-ERROR was detected in function STD-SLOT-VALUE: ;;; Error: The slot COMMON-LISP::EFFECTIVE-SLOTS is missing from the class #<Standard-Class BUILT-IN-CLASS #x614B3A0>. ;;; Entering Corman Lisp debug loop. ;;; Use :C followed by an option to exit. Type :HELP for help. ;;; Restart options: ;;; 1 Abort to top level.

But, I see on my macbook Clozure CL seems happy with nil for SPECIALIZERS and gives ? (setf return (make-instance 'standard-method :lambda-list '(foo) :function #'(lambda (foo) foo))) #<STANDARD-METHOD NIL NIL> ? (describe return) #<STANDARD-METHOD NIL NIL> Class: #<STANDARD-CLASS STANDARD-METHOD> Wrapper: #<CCL::CLASS-WRAPPER STANDARD-METHOD #x302000017FAD> Instance slots CCL::QUALIFIERS: NIL CCL::SPECIALIZERS: NIL FUNCTION: #<Compiled-function #<STANDARD-METHOD NIL NIL> (Non-Global) #x302000D3341F> GENERIC-FUNCTION: NIL CCL::NAME: NIL CCL::LAMBDA-LIST: (FOO) ?

nigel3289 avatar Jun 07 '19 02:06 nigel3289

Thanks for reporting the problem! I might investigate it later, but it is low priority now.

arbv avatar Jul 08 '19 13:07 arbv