Re: [Sbcl-devel] sbcl style

On Tue, Jan 22, 2002 at 10:52:57PM +0100, Stig E Sandoe wrote:
> Quoting Raymond Toy (toy@...):
> | >>>>> "Stig" == Stig E Sandoe <stig@...> writes:
> |
> | Stig> Quoting Stig E Sandoe (stig@...):
> | Stig> | hi,
> | Stig> |
> | Stig> | being a fresh sbcl-user I am obviously not accustomed to SBCL's
> | Stig> | perception of style yet, and I understand that this takes time
> | Stig> | to learn. But how can I turn off the noisy style-warnings till I
> | Stig> | learn good style and sbcl manners? :)
> |
> | Stig> I'll follow up on my own message here. One of the more annoying
> | Stig> and useless messages is:
> |
> | Stig> ; in: LAMBDA (#:WHOLE169 #:ENVIRONMENT170)
> | Stig> ; (CONSP SB-PCL::CNM-ARGS)
> | Stig> ;
> | Stig> ; note: deleting unreachable code
> |
> | Are you complaining about the unreachable code note?
> |
> | I've found such notes very, very helpful because if I can't figure out
> | why it says that, I've usually done something very, very wrong.
OK, I'm much more enthusiastic about suppressing optimization notes
than I'd be about suppressing style warnings.
(There is a meaningful distinction there. Admittedly, they might both
look like annoying noise at this point, and admittedly the
optimization notes part of what might be called compiler warnings in a
non-Common-Lisp system. However, the Common Lisp spec has some
specific things to say about WARNINGS-P and FAILURE-P return values of
COMPILE-FILE, and their relationship to the condition class
STYLE-WARNING, and the STYLE-WARNING conditions are what I'm referring
to when I refer to style warnings. I've spent a fair amount of time
trying to make SBCL get this right, after suffering a fair amount of
frustration at CMU CL getting it wrong, and now I'm motivated to be
pedantic about it.)
I don't remember offhand how to do it, but there used to be ways to
suppress optimization notes. If that functionality hasn't been
maintained in SBCL, it could be added back in, either with the same
interface or a new one.
I dimly remember at least one thing like this, maybe
(DECLARE (OPTIMIZE (VERBOSITY FOO)))
and I disliked it because I (1) didn't particularly think of it as
an optimization quality, and (2) ANSI provides a mechanism,
(DECLAIM (DECLARATION FOO)), for people to avoid warnings
about foreign declaration specifiers in portable code, bug
stuffing the extension into optimization qualities defeated
this mechanism.
Perhaps something like
(DECLAIM (NOTES 1))
or
(DECLAIM (NOTES-DEFAULT 1))
could be used to control compiler notes?
The exact behavior might requires some thinking and tweaking, since
typically people compiling with high values of (OPTIMIZE (SPEED ...))
want more optimization notes, even if they don't mess with
extensions like (DECLAIM (NOTES ...)), while people who sit down
and start typing at SBCL without DECLAIMing anything probably
don't much care for optimization notes. CMU CL does this already,
so at some point I should take a look at it.
--
William Harold Newman <william.newman@...>
"Look on my works, ye Mighty, and despair!" -- Ozymandias, King of Kings
PGP key fingerprint 85 CE 1C BA 79 8D 51 8C B9 25 FB EE E0 C3 E5 7C

Thread view

hi,
being a fresh sbcl-user I am obviously not accustomed to SBCL's
perception of style yet, and I understand that this takes time
to learn. But how can I turn off the noisy style-warnings till I
learn good style and sbcl manners? :)
--
------------------------------------------------------------------
Stig Erik Sandoe stig@... http://www.ii.uib.no/~stig/

On Tue, Jan 22, 2002 at 08:54:53PM +0100, Stig E Sandoe wrote:
> being a fresh sbcl-user I am obviously not accustomed to SBCL's
> perception of style yet, and I understand that this takes time
> to learn. But how can I turn off the noisy style-warnings till I
> learn good style and sbcl manners? :)
Right now, I can't think of any good way to suppress them other
than writing your code in a sufficiently painstaking, pedantic
way that SBCL doesn't pester you about it.
Incidentally, are there any particular warnings that you or anyone
else find to be particularly obnoxious? Maybe some of them are more
screwed up than I realize. However, so far I've been reasonably
successful at writing applications so that they compile without
issuing any style warnings. The only nonobvious trick involved that I
can think of is that SBCL treats the idiom
(DECLAIM (FTYPE FUNCTION FOO))
as a forward declaration of FOO, suitable for avoiding warnings
about undefined functions.
I'm a fairly big believer in style warnings because there are a lot of
things, e.g. almost-certainly-doomed-to-fail code like
(defun foo (x y z)
(frob x y z))
(defun bar (z)
;; Now let's call FOO with the wrong number of args.
(foo z z))
or very-likely-unintended-to-work-this-way code
(defun foo (x y z) ; the new definition, cut and pasted to here
(pre-frob x y)
(frob x y z))
... ; a few hundred lines of code
(defun foo (x y z) ; the old definition, forgot to delete it
(frob x y z))
which are much easier to spot if the compiler complains. But maybe
for some people's coding styles it's a problem.
--
William Harold Newman <william.newman@...>
"Look on my works, ye Mighty, and despair!" -- Ozymandias, King of Kings
PGP key fingerprint 85 CE 1C BA 79 8D 51 8C B9 25 FB EE E0 C3 E5 7C

Quoting William Harold Newman (william.newman@...):
| On Tue, Jan 22, 2002 at 08:54:53PM +0100, Stig E Sandoe wrote:
| > being a fresh sbcl-user I am obviously not accustomed to SBCL's
| > perception of style yet, and I understand that this takes time
| > to learn. But how can I turn off the noisy style-warnings till I
| > learn good style and sbcl manners? :)
|
| Right now, I can't think of any good way to suppress them other
| than writing your code in a sufficiently painstaking, pedantic
| way that SBCL doesn't pester you about it.
CMUCL can also be excessively chatty, but at least you can use
EXT:INHIBIT-WARNINGS, would it be possible to tailour SBCL's
excessive talking through a similar mechanism?
| Incidentally, are there any particular warnings that you or anyone
| else find to be particularly obnoxious? Maybe some of them are more
| screwed up than I realize.
Cf another mail in the thread, another warning that gives absolutely no
meaning is:
; file: /home/stig/Projects/langband/monster.lisp
; in: DEFMETHOD PRINT-OBJECT (ACTIVE-MONSTER T)
; (CLASS-OF ORG.LANGBAND.ENGINE::INST)
; --> BLOCK SB-KERNEL:LAYOUT-CLASS SB-KERNEL:LAYOUT-OF BLOCK COND IF COND
IF
; --> COND IF PROGN LOCALLY
; ==>
; (SB-KERNEL:CLASS-LAYOUT (FIND-CLASS 'NULL))
;
; note: deleting unused function
; SB-KERNEL:CLASS-LAYOUT
Stuff like this is internal implementation-details and not of interest
with default warning-settings. I don't really want to know about
optimisations of SBCL-added code, I want to know aabout my app-code.
| However, so far I've been reasonably
| successful at writing applications so that they compile without
| issuing any style warnings. The only nonobvious trick involved that I
| can think of is that SBCL treats the idiom
| (DECLAIM (FTYPE FUNCTION FOO))
| as a forward declaration of FOO, suitable for avoiding warnings
| about undefined functions.
A good hint. Please put it on a web-page or a sbcl-manual easily
accessible from the web-page.
| I'm a fairly big believer in style warnings because there are a lot of
| things, e.g. almost-certainly-doomed-to-fail code like
| (defun foo (x y z)
| (frob x y z))
| (defun bar (z)
| ;; Now let's call FOO with the wrong number of args.
| (foo z z))
| or very-likely-unintended-to-work-this-way code
| (defun foo (x y z) ; the new definition, cut and pasted to here
| (pre-frob x y)
| (frob x y z))
| ... ; a few hundred lines of code
| (defun foo (x y z) ; the old definition, forgot to delete it
| (frob x y z))
| which are much easier to spot if the compiler complains. But maybe
| for some people's coding styles it's a problem.
As long as it is code in the application-domain I'm not too opposed, but
when it is code that is generated by the SBCL-compiler I don't want to
know about it. I have enough to worry about on the app-side.
One warning I like with SBCL is that of implicit DEFGENERICs. That
applies to _my_ code and is something I _should_ improve.
Lots of good work on SBCL, but it needs more work before it's usable for
my apps (cf today's reports). So keep up the good work :)
--
------------------------------------------------------------------
Stig Erik Sandoe stig@... http://www.ii.uib.no/~stig/

>>>>> "Stig" == Stig E Sandoe <stig@...> writes:
Stig> Quoting Stig E Sandoe (stig@...):
Stig> | hi,
Stig> |
Stig> | being a fresh sbcl-user I am obviously not accustomed to SBCL's
Stig> | perception of style yet, and I understand that this takes time
Stig> | to learn. But how can I turn off the noisy style-warnings till I
Stig> | learn good style and sbcl manners? :)
Stig> I'll follow up on my own message here. One of the more annoying
Stig> and useless messages is:
Stig> ; in: LAMBDA (#:WHOLE169 #:ENVIRONMENT170)
Stig> ; (CONSP SB-PCL::CNM-ARGS)
Stig> ;
Stig> ; note: deleting unreachable code
Are you complaining about the unreachable code note?
I've found such notes very, very helpful because if I can't figure out
why it says that, I've usually done something very, very wrong.
I do, however, agree that such notes that come from some macro that I
didn't write are annoying because there's usually nothing I can do
about it except rewrite the macro not to generate unreachable code.
But you can't always do that either.
Ray

Quoting Raymond Toy (toy@...):
| >>>>> "Stig" == Stig E Sandoe <stig@...> writes:
|
| Stig> Quoting Stig E Sandoe (stig@...):
| Stig> | hi,
| Stig> |
| Stig> | being a fresh sbcl-user I am obviously not accustomed to SBCL's
| Stig> | perception of style yet, and I understand that this takes time
| Stig> | to learn. But how can I turn off the noisy style-warnings till I
| Stig> | learn good style and sbcl manners? :)
|
| Stig> I'll follow up on my own message here. One of the more annoying
| Stig> and useless messages is:
|
| Stig> ; in: LAMBDA (#:WHOLE169 #:ENVIRONMENT170)
| Stig> ; (CONSP SB-PCL::CNM-ARGS)
| Stig> ;
| Stig> ; note: deleting unreachable code
|
| Are you complaining about the unreachable code note?
|
| I've found such notes very, very helpful because if I can't figure out
| why it says that, I've usually done something very, very wrong.
Yes, I agree with that, and usually CMUCL's warnings have been good.
| I do, however, agree that such notes that come from some macro that I
| didn't write are annoying because there's usually nothing I can do
| about it except rewrite the macro not to generate unreachable code.
| But you can't always do that either.
The problem is that I have no idea where it comes from, except it
seems to come from PCL and some optimisation of method-lookups.
Which is fascinating, but I see PCL as internal details for SBCL (or
CMUCL or whatever) and if I'm writing kosher CLOS-code I really don't want
to move through page after page of what the heck SBCL and PCL
optimises my calls to. That is apparently what is happening now.
The useful messages get lost in this noise.
If it is indeed a problem with my code, it's impossible for me to get that
info from the note above, as it doesn't say where the code is or which
code it calls.
--
------------------------------------------------------------------
Stig Erik Sandoe stig@... http://www.ii.uib.no/~stig/

On Tue, Jan 22, 2002 at 10:52:57PM +0100, Stig E Sandoe wrote:
> Quoting Raymond Toy (toy@...):
> | >>>>> "Stig" == Stig E Sandoe <stig@...> writes:
> |
> | Stig> Quoting Stig E Sandoe (stig@...):
> | Stig> | hi,
> | Stig> |
> | Stig> | being a fresh sbcl-user I am obviously not accustomed to SBCL's
> | Stig> | perception of style yet, and I understand that this takes time
> | Stig> | to learn. But how can I turn off the noisy style-warnings till I
> | Stig> | learn good style and sbcl manners? :)
> |
> | Stig> I'll follow up on my own message here. One of the more annoying
> | Stig> and useless messages is:
> |
> | Stig> ; in: LAMBDA (#:WHOLE169 #:ENVIRONMENT170)
> | Stig> ; (CONSP SB-PCL::CNM-ARGS)
> | Stig> ;
> | Stig> ; note: deleting unreachable code
> |
> | Are you complaining about the unreachable code note?
> |
> | I've found such notes very, very helpful because if I can't figure out
> | why it says that, I've usually done something very, very wrong.
OK, I'm much more enthusiastic about suppressing optimization notes
than I'd be about suppressing style warnings.
(There is a meaningful distinction there. Admittedly, they might both
look like annoying noise at this point, and admittedly the
optimization notes part of what might be called compiler warnings in a
non-Common-Lisp system. However, the Common Lisp spec has some
specific things to say about WARNINGS-P and FAILURE-P return values of
COMPILE-FILE, and their relationship to the condition class
STYLE-WARNING, and the STYLE-WARNING conditions are what I'm referring
to when I refer to style warnings. I've spent a fair amount of time
trying to make SBCL get this right, after suffering a fair amount of
frustration at CMU CL getting it wrong, and now I'm motivated to be
pedantic about it.)
I don't remember offhand how to do it, but there used to be ways to
suppress optimization notes. If that functionality hasn't been
maintained in SBCL, it could be added back in, either with the same
interface or a new one.
I dimly remember at least one thing like this, maybe
(DECLARE (OPTIMIZE (VERBOSITY FOO)))
and I disliked it because I (1) didn't particularly think of it as
an optimization quality, and (2) ANSI provides a mechanism,
(DECLAIM (DECLARATION FOO)), for people to avoid warnings
about foreign declaration specifiers in portable code, bug
stuffing the extension into optimization qualities defeated
this mechanism.
Perhaps something like
(DECLAIM (NOTES 1))
or
(DECLAIM (NOTES-DEFAULT 1))
could be used to control compiler notes?
The exact behavior might requires some thinking and tweaking, since
typically people compiling with high values of (OPTIMIZE (SPEED ...))
want more optimization notes, even if they don't mess with
extensions like (DECLAIM (NOTES ...)), while people who sit down
and start typing at SBCL without DECLAIMing anything probably
don't much care for optimization notes. CMU CL does this already,
so at some point I should take a look at it.
--
William Harold Newman <william.newman@...>
"Look on my works, ye Mighty, and despair!" -- Ozymandias, King of Kings
PGP key fingerprint 85 CE 1C BA 79 8D 51 8C B9 25 FB EE E0 C3 E5 7C

Quoting William Harold Newman (william.newman@...):
| On Tue, Jan 22, 2002 at 10:52:57PM +0100, Stig E Sandoe wrote:
| > Quoting Raymond Toy (toy@...):
| > | >>>>> "Stig" == Stig E Sandoe <stig@...> writes:
| > |
| > | Stig> Quoting Stig E Sandoe (stig@...):
| > | Stig> | hi,
| > | Stig> |
| > | Stig> | being a fresh sbcl-user I am obviously not accustomed to SBCL's
| > | Stig> | perception of style yet, and I understand that this takes time
| > | Stig> | to learn. But how can I turn off the noisy style-warnings till I
| > | Stig> | learn good style and sbcl manners? :)
| > |
| > | Stig> I'll follow up on my own message here. One of the more annoying
| > | Stig> and useless messages is:
| > |
| > | Stig> ; in: LAMBDA (#:WHOLE169 #:ENVIRONMENT170)
| > | Stig> ; (CONSP SB-PCL::CNM-ARGS)
| > | Stig> ;
| > | Stig> ; note: deleting unreachable code
| > |
| > | Are you complaining about the unreachable code note?
| > |
| > | I've found such notes very, very helpful because if I can't figure out
| > | why it says that, I've usually done something very, very wrong.
|
| OK, I'm much more enthusiastic about suppressing optimization notes
| than I'd be about suppressing style warnings.
A further check on my side reveals that I got rid of the above
chatting with a declaration:
#+sbcl (sb-ext:inhibit-warnings 3)
But I really think this kind of notes should be at warning level 1,
not at level 2.
| (There is a meaningful distinction there. Admittedly, they might both
| look like annoying noise at this point, and admittedly the
| optimization notes part of what might be called compiler warnings in a
| non-Common-Lisp system. However, the Common Lisp spec has some
| specific things to say about WARNINGS-P and FAILURE-P return values of
| COMPILE-FILE, and their relationship to the condition class
| STYLE-WARNING, and the STYLE-WARNING conditions are what I'm referring
| to when I refer to style warnings. I've spent a fair amount of time
| trying to make SBCL get this right, after suffering a fair amount of
| frustration at CMU CL getting it wrong, and now I'm motivated to be
| pedantic about it.)
|
| I don't remember offhand how to do it, but there used to be ways to
| suppress optimization notes. If that functionality hasn't been
| maintained in SBCL, it could be added back in, either with the same
| interface or a new one.
ok, the above declaration made things a bit easier, but it gets too noisy
at level 2. level 2 tends to be useful at cmucl.
| I dimly remember at least one thing like this, maybe
| (DECLARE (OPTIMIZE (VERBOSITY FOO)))
| and I disliked it because I (1) didn't particularly think of it as
| an optimization quality, and (2) ANSI provides a mechanism,
| (DECLAIM (DECLARATION FOO)), for people to avoid warnings
| about foreign declaration specifiers in portable code, bug
| stuffing the extension into optimization qualities defeated
| this mechanism.
|
| Perhaps something like
| (DECLAIM (NOTES 1))
| or
| (DECLAIM (NOTES-DEFAULT 1))
| could be used to control compiler notes?
That sounds like an improvement.
| The exact behavior might requires some thinking and tweaking, since
| typically people compiling with high values of (OPTIMIZE (SPEED ...))
| want more optimization notes, even if they don't mess with
| extensions like (DECLAIM (NOTES ...)), while people who sit down
| and start typing at SBCL without DECLAIMing anything probably
| don't much care for optimization notes. CMU CL does this already,
| so at some point I should take a look at it.
ok, this is not my biggest problem atm but for future versions I hope
it'll be included. :)
--
------------------------------------------------------------------
Stig Erik Sandoe stig@... http://www.ii.uib.no/~stig/