From: james a. <jam...@se...> - 2010-02-12 13:24:21
|
good afternoon; it appears that sbcl recognizes a prior class definition at compile time at top level or in a top level progn only. in the code below, the progn-only approaches compile uneventfully while the others elicit warnings. is there something to learn from this, or does one just structure definition macros accordingly? the "muffling" protocol reads as if it offers control specific to deletion notes only. is it possible to arrange to muffle this particular style warning? --- ;;; -*- Package: de.setf.amqp.implementation; -*- (in-package :de.setf.amqp.implementation) (eval-when (:compile-toplevel) (print 'progn)) (progn (defclass progn-class () ()) (defmethod progn-method ((argument progn-class)) argument) (find-class 'progn-class)) (eval-when (:compile-toplevel) (print 'prog1)) (prog1 (defclass prog1-class () ()) (defmethod prog1-method ((argument prog1-class)) argument)) (eval-when (:compile-toplevel) (print 'let)) (let ((class (defclass let-class () ()))) (defmethod let-method ((argument let-class)) argument) class) (eval-when (:compile-toplevel) (print 'setf)) (let ((class nil)) (setf class (defclass setf-class () ())) (defmethod setf-method ((argument setf-class)) argument) class) (eval-when (:compile-toplevel) (print 'let-progn)) (let ((something 0)) (eq something (get-universal-time)) (progn (defclass let-progn-class () ()) (defmethod let-progn-method ((argument let-progn-class)) argument) (find-class 'let-progn-class))) (eval-when (:compile-toplevel) (print 'progn-progn)) (progn (let ((something 0)) (eq something (get-universal-time))) (progn (defclass progn-progn-class () ()) (defmethod progn-progn-method ((argument progn-progn-class)) argument) (find-class 'progn-progn-class))) --- * (compile-file "AMQP:test-compile.lisp") ; compiling file "/Development/Source/dev/Library/de/setf/amqp/test- compile.lisp" (written 12 FEB 2010 01:46:41 PM): ; compiling (IN-PACKAGE :DE.SETF.AMQP.IMPLEMENTATION) PROGN ; compiling (DEFCLASS PROGN-CLASS ...) ; compiling (DEFMETHOD PROGN-METHOD ...) ; compiling (FIND-CLASS (QUOTE PROGN-CLASS)) PROG1 ; compiling (PROG1 (DEFCLASS PROG1-CLASS ...) ...) ; file: /Development/Source/dev/Library/de/setf/amqp/test-compile.lisp ; in: PROG1 (DEFCLASS PROG1-CLASS NIL NIL) ; (PROG1 (DEFCLASS DE.SETF.AMQP.IMPLEMENTATION::PROG1-CLASS NIL NIL) ; (DEFMETHOD DE.SETF.AMQP.IMPLEMENTATION::PROG1-METHOD ; ((DE.SETF.AMQP.IMPLEMENTATION::ARGUMENT ; DE.SETF.AMQP.IMPLEMENTATION::PROG1-CLASS)) ; DE.SETF.AMQP.IMPLEMENTATION::ARGUMENT)) ; ==> ; (LET ((#:G4 (DEFCLASS DE.SETF.AMQP.IMPLEMENTATION::PROG1-CLASS NIL NIL))) ; (DEFMETHOD DE.SETF.AMQP.IMPLEMENTATION::PROG1-METHOD ; ((DE.SETF.AMQP.IMPLEMENTATION::ARGUMENT ; DE.SETF.AMQP.IMPLEMENTATION::PROG1-CLASS)) ; DE.SETF.AMQP.IMPLEMENTATION::ARGUMENT) ; #:G4) ; ; caught STYLE-WARNING: ; can't find type for specializer PROG1-CLASS in ; SB-PCL::PARAMETER-SPECIALIZER-DECLARATION-IN-DEFMETHOD. ; in: DEFMETHOD PROG1-METHOD (PROG1-CLASS) ; (DEFMETHOD DE.SETF.AMQP.IMPLEMENTATION::PROG1-METHOD ; ((DE.SETF.AMQP.IMPLEMENTATION::ARGUMENT ; DE.SETF.AMQP.IMPLEMENTATION::PROG1-CLASS)) ; DE.SETF.AMQP.IMPLEMENTATION::ARGUMENT) ; --> PROGN EVAL-WHEN ; ==> ; (SB-PCL::%DEFMETHOD-EXPANDER DE.SETF.AMQP.IMPLEMENTATION::PROG1- METHOD NIL ; ((DE.SETF.AMQP.IMPLEMENTATION::ARGUMENT ; DE.SETF.AMQP.IMPLEMENTATION::PROG1- CLASS)) ; (DE.SETF.AMQP.IMPLEMENTATION::ARGUMENT)) ; ; caught STYLE-WARNING: ; (in macroexpansion of (SB-PCL::%DEFMETHOD-EXPANDER PROG1-METHOD NIL ...)) ; (hint: For more precise location, try *BREAK-ON-SIGNALS*.) ; can't find type for specializer PROG1-CLASS in ; SB-PCL::PARAMETER-SPECIALIZER-DECLARATION-IN-DEFMETHOD. LET ; compiling (LET (#) ...) ; file: /Development/Source/dev/Library/de/setf/amqp/test-compile.lisp ; in: LET ((CLASS (DEFCLASS LET-CLASS NIL NIL))) ; (LET ((CLASS (DEFCLASS DE.SETF.AMQP.IMPLEMENTATION::LET-CLASS NIL NIL))) ; (DEFMETHOD DE.SETF.AMQP.IMPLEMENTATION::LET-METHOD ; ((DE.SETF.AMQP.IMPLEMENTATION::ARGUMENT ; DE.SETF.AMQP.IMPLEMENTATION::LET-CLASS)) ; DE.SETF.AMQP.IMPLEMENTATION::ARGUMENT) ; CLASS) ; ; caught STYLE-WARNING: ; can't find type for specializer LET-CLASS in ; SB-PCL::PARAMETER-SPECIALIZER-DECLARATION-IN-DEFMETHOD. ; in: DEFMETHOD LET-METHOD (LET-CLASS) ; (DEFMETHOD DE.SETF.AMQP.IMPLEMENTATION::LET-METHOD ; ((DE.SETF.AMQP.IMPLEMENTATION::ARGUMENT ; DE.SETF.AMQP.IMPLEMENTATION::LET-CLASS)) ; DE.SETF.AMQP.IMPLEMENTATION::ARGUMENT) ; --> PROGN EVAL-WHEN ; ==> ; (SB-PCL::%DEFMETHOD-EXPANDER DE.SETF.AMQP.IMPLEMENTATION::LET- METHOD NIL ; ((DE.SETF.AMQP.IMPLEMENTATION::ARGUMENT ; DE.SETF.AMQP.IMPLEMENTATION::LET- CLASS)) ; (DE.SETF.AMQP.IMPLEMENTATION::ARGUMENT)) ; ; caught STYLE-WARNING: ; (in macroexpansion of (SB-PCL::%DEFMETHOD-EXPANDER LET-METHOD NIL ...)) ; (hint: For more precise location, try *BREAK-ON-SIGNALS*.) ; can't find type for specializer LET-CLASS in ; SB-PCL::PARAMETER-SPECIALIZER-DECLARATION-IN-DEFMETHOD. SETF ; compiling (LET (#) ...) ; file: /Development/Source/dev/Library/de/setf/amqp/test-compile.lisp ; in: DEFMETHOD SETF-METHOD (SETF-CLASS) ; (DEFMETHOD DE.SETF.AMQP.IMPLEMENTATION::SETF-METHOD ; ((DE.SETF.AMQP.IMPLEMENTATION::ARGUMENT ; DE.SETF.AMQP.IMPLEMENTATION::SETF-CLASS)) ; DE.SETF.AMQP.IMPLEMENTATION::ARGUMENT) ; --> PROGN EVAL-WHEN ; ==> ; (SB-PCL::%DEFMETHOD-EXPANDER DE.SETF.AMQP.IMPLEMENTATION::SETF- METHOD NIL ; ((DE.SETF.AMQP.IMPLEMENTATION::ARGUMENT ; DE.SETF.AMQP.IMPLEMENTATION::SETF- CLASS)) ; (DE.SETF.AMQP.IMPLEMENTATION::ARGUMENT)) ; ; caught STYLE-WARNING: ; (in macroexpansion of (SB-PCL::%DEFMETHOD-EXPANDER SETF-METHOD NIL ...)) ; (hint: For more precise location, try *BREAK-ON-SIGNALS*.) ; can't find type for specializer SETF-CLASS in ; SB-PCL::PARAMETER-SPECIALIZER-DECLARATION-IN-DEFMETHOD. LET-PROGN ; compiling (LET (#) ...) ; file: /Development/Source/dev/Library/de/setf/amqp/test-compile.lisp ; in: LET ((SOMETHING 0)) ; (LET ((DE.SETF.AMQP.IMPLEMENTATION::SOMETHING 0)) ; (EQ DE.SETF.AMQP.IMPLEMENTATION::SOMETHING (GET-UNIVERSAL-TIME)) ; (PROGN ; (DEFCLASS DE.SETF.AMQP.IMPLEMENTATION::LET-PROGN-CLASS NIL NIL) ; (DEFMETHOD DE.SETF.AMQP.IMPLEMENTATION::LET-PROGN-METHOD ; ((DE.SETF.AMQP.IMPLEMENTATION::ARGUMENT ; DE.SETF.AMQP.IMPLEMENTATION::LET-PROGN-CLASS)) ; DE.SETF.AMQP.IMPLEMENTATION::ARGUMENT) ; (FIND-CLASS 'DE.SETF.AMQP.IMPLEMENTATION::LET-PROGN-CLASS))) ; ; caught STYLE-WARNING: ; can't find type for specializer LET-PROGN-CLASS in ; SB-PCL::PARAMETER-SPECIALIZER-DECLARATION-IN-DEFMETHOD. ; in: DEFMETHOD LET-PROGN-METHOD (LET-PROGN-CLASS) ; (DEFMETHOD DE.SETF.AMQP.IMPLEMENTATION::LET-PROGN-METHOD ; ((DE.SETF.AMQP.IMPLEMENTATION::ARGUMENT ; DE.SETF.AMQP.IMPLEMENTATION::LET-PROGN-CLASS)) ; DE.SETF.AMQP.IMPLEMENTATION::ARGUMENT) ; --> PROGN EVAL-WHEN ; ==> ; (SB-PCL::%DEFMETHOD-EXPANDER DE.SETF.AMQP.IMPLEMENTATION::LET- PROGN-METHOD ; NIL ; ((DE.SETF.AMQP.IMPLEMENTATION::ARGUMENT ; DE.SETF.AMQP.IMPLEMENTATION::LET- PROGN-CLASS)) ; (DE.SETF.AMQP.IMPLEMENTATION::ARGUMENT)) ; ; caught STYLE-WARNING: ; (in macroexpansion of (SB-PCL::%DEFMETHOD-EXPANDER LET-PROGN- METHOD NIL ...)) ; (hint: For more precise location, try *BREAK-ON-SIGNALS*.) ; can't find type for specializer LET-PROGN-CLASS in ; SB-PCL::PARAMETER-SPECIALIZER-DECLARATION-IN-DEFMETHOD. PROGN-PROGN ; compiling (LET (#) ...) ; compiling (DEFCLASS PROGN-PROGN-CLASS ...) ; compiling (DEFMETHOD PROGN-PROGN-METHOD ...) ; compiling (FIND-CLASS (QUOTE PROGN-PROGN-CLASS)); ; compilation unit finished ; caught 7 STYLE-WARNING conditions ; AMQP:TEST-COMPILE.FASL.NEWEST written ; compilation finished in 0:00:00.194 #P"/Development/Source/dev/Library/de/setf/amqp/bin/sbcl-osx/test- compile.fasl" T NIL * (sb-mop:class-direct-subclasses (find-class 'sb-ext:compiler-note)) (#<SB-PCL::CONDITION-CLASS SB-INT:SIMPLE-COMPILER-NOTE>) * (sb-mop:class-direct-subclasses (find-class 'SB-INT:SIMPLE-COMPILER- NOTE)) (#<SB-PCL::CONDITION-CLASS CODE-DELETION-NOTE>) * (lisp-implementation-version) "1.0.35" * |
From: Tobias C. R. <tc...@fr...> - 2010-02-13 10:37:01
|
james anderson <jam...@se...> writes: > good afternoon; > > it appears that sbcl recognizes a prior class definition at compile > time at top level or in a top level progn only. > in the code below, the progn-only approaches compile uneventfully > while the others elicit warnings. > is there something to learn from this, or does one just structure > definition macros accordingly? Last paragraph of CLHS defclass tells: If a defclass form appears as a top level form, the compiler must make the class name be recognized as a valid type name in subsequent declarations (as for deftype) and be recognized as a valid class name for defmethod parameter specializers and ... Now looking into the source of where that style-warning is signaled, that place is responsible for declaring types to Python in the internal method-lambda. However, the actual relevant part in the code looks like: (if (typep class '(or built-in-class structure-class)) `(type ,class ,parameter) ;; don't declare CLOS classes as parameters; ;; it's too expensive. '(ignorable)) Because in your case, it's all CLOS classes it does not actually make any difference there. However, there may be other parts in PCL which just silently give up and fall back to a very slow path. > the "muffling" protocol reads as if it offers control specific to > deletion notes only. > is it possible to arrange to muffle this particular style warning? MUFFLE-CONDITIONS is, as far as I read, applicable to anything with a MUFFLE-WARNING restart which includes conditions signaled by means of WARN, and also internal compiler conditions. However, to muffle a particular condition, it needs to have its own name so you can discriminate it from other conditions. In this particular case, the code only signals a general style-warning, and muffling all style-warning sounds like a very bad recipe. I'm also not convinced that muffling that particular condition would be a good idea to begin with. An actual PCL expert might want to chime in here, and explain the pessimistics things that would result from using non-toplevel DEFCLASS + specializing DEFMETHODS in the same file. If you really need non-toplevel DEFCLASSes, you should consider moving them into their own file, loaded before their uses. -T. |