[Sbcl-devel] Misleading style warnings from PCL, continued...

Hi!
Again, I stepped on a misleading style warning when using CLOS. This
is the minimal test case I could extract:
(defgeneric bar (x))
(bar
(make-instance
(prog1 (defclass foo nil nil) (defmethod bar ((x foo))))))
The call to defmethod complains about a missing type for specializer
foo, while the specs for prog1 state that the side effects of
evaluating the first form (the class definition) have to affect the
following forms.
The following attempt to reimplement prog1 does not solve the problem:
(defmacro prog1 (car &body cdr)
(let ((result (gensym)))
`(let ((,result ,car))
,@cdr
,result)))
Without saving the first value in a lexical binding (thereby polluting
the global namespace and creating a problem for concurrent
computation), the test case executes without warning:
(defmacro prog1 (car &body cdr)
(let ((result (gensym)))
`(progn (defvar ,result ,car) ,@cdr ,result)))
However, this one creates a warning when used inside more complex
forms, where a function body is sufficient for being "more complex":
(defgeneric bar (x))
(defun baz ()
(make-instance
(prog1 (defclass foo nil nil) (defmethod bar ((x foo))))))
(bar (baz))
It seems like the hook creating the "undefined variable" warnings
doesn't understand defvar in a non-top environment.
Best regards,
Isidor

Thread view

Hi!
Again, I stepped on a misleading style warning when using CLOS. This
is the minimal test case I could extract:
(defgeneric bar (x))
(bar
(make-instance
(prog1 (defclass foo nil nil) (defmethod bar ((x foo))))))
The call to defmethod complains about a missing type for specializer
foo, while the specs for prog1 state that the side effects of
evaluating the first form (the class definition) have to affect the
following forms.
The following attempt to reimplement prog1 does not solve the problem:
(defmacro prog1 (car &body cdr)
(let ((result (gensym)))
`(let ((,result ,car))
,@cdr
,result)))
Without saving the first value in a lexical binding (thereby polluting
the global namespace and creating a problem for concurrent
computation), the test case executes without warning:
(defmacro prog1 (car &body cdr)
(let ((result (gensym)))
`(progn (defvar ,result ,car) ,@cdr ,result)))
However, this one creates a warning when used inside more complex
forms, where a function body is sufficient for being "more complex":
(defgeneric bar (x))
(defun baz ()
(make-instance
(prog1 (defclass foo nil nil) (defmethod bar ((x foo))))))
(bar (baz))
It seems like the hook creating the "undefined variable" warnings
doesn't understand defvar in a non-top environment.
Best regards,
Isidor

Community

Help

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

CountryState

JavaScript is required for this form.

I agree to receive quotes, newsletters and other information from sourceforge.net and its partners regarding IT services and products. I understand that I can withdraw my consent at any time. Please refer to our Privacy Policy or Contact Us for more details