Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when trying to create STANDARD-METHOD instances. #59

Open
j3pic opened this issue Apr 21, 2019 · 2 comments
Open

Error when trying to create STANDARD-METHOD instances. #59

j3pic opened this issue Apr 21, 2019 · 2 comments

Comments

@j3pic
Copy link

j3pic commented Apr 21, 2019

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}>
@nigel3289
Copy link

nigel3289 commented Jun 7, 2019

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 (#) {1003A03E53}>
CL-USER> (describe return)
#<STANDARD-METHOD (#) {100..
[standard-object]

Slots with :INSTANCE allocation:
SOURCE = NIL
PLIST = NIL
%GENERIC-FUNCTION = NIL
QUALIFIERS = NIL
SPECIALIZERS = (#)
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 (#)>
[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)))
#
? (describe return)
#
Class: #
Wrapper: #<CCL::CLASS-WRAPPER STANDARD-METHOD #x302000017FAD>
Instance slots
CCL::QUALIFIERS: NIL
CCL::SPECIALIZERS: NIL
FUNCTION: #<Compiled-function # (Non-Global) #x302000D3341F>
GENERIC-FUNCTION: NIL
CCL::NAME: NIL
CCL::LAMBDA-LIST: (FOO)
?

@arbv
Copy link
Member

arbv commented Jul 8, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants