unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Mark H Weaver <mhw@netris.org>
To: ludo@gnu.org (Ludovic Courtès)
Cc: guile-devel@gnu.org
Subject: Re: Let's fix how warnings are specified
Date: Tue, 14 Feb 2012 11:56:58 -0500	[thread overview]
Message-ID: <87hayt4alh.fsf@netris.org> (raw)
In-Reply-To: <87pqdhwm45.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Tue, 14 Feb 2012 15:00:42 +0100")

ludo@gnu.org (Ludovic Courtès) writes:

> Mark H Weaver <mhw@netris.org> skribis:
>
>> Here's a preliminary proposal:
>>
>> * Add new pseudo-warning types 'all' and 'default'.
>
> Yes, but only at the UI level–i.e., in ‘guild compile’, along with
> ‘help’.

The fundamental problem with this strategy is that it requires a
centralized master list of warning types, which makes it very awkward
for users to add their own new warning types that can be explicitly
disabled.

I'd like users to be able to write this within a procedural macro:

  (if (warning-requested? 'my-new-warning #t)
      (my-new-warning-pass x))

The second argument to 'warning-requested?' specifies whether this new
warning is in the 'default' set of warnings.

I already have a patch set that implements this.  It is simple to
implement and convenient to use.  There is no comprehensive centralized
list of warnings.  'warning-requested?' is implemented like this:

  (define* (warning-requested? name
                               #:optional
                               (default? #t)
                               (spec (fluid-ref *requested-warnings-spec*)))
    (and (or (memq name spec)
             (memq 'all spec)
             (and default? (memq 'default spec)))
         (not (memq (symbol-append 'no- name) spec))))

The warning message includes the name of the warning type, so if the
user sees too many spurious warnings of that type, they can easily
disable it.

With your strategy, please consider what would be required for a library
author to export a macro that issues a new warning type that can be
disabled by the user.  The warning would not be shown unless users of
the library arranged to extend their centralized %warning-types,
%default-warning-types, %auto-compilation-options, and possibly their
own code that calls 'compile'.

Given all this hassle, it is likely that library writers will simply
issue warnings that cannot be disabled, or that must be disabled using a
non-standard mechanism.

> At the programming level there are better ways to do this, namely
> (map car %warning-types) and %auto-compilation-options.

Even for users, this is very awkward.  From a user's perspective, the
most common case (apart from using all defaults) is to _disable_ one or
more warnings, but to otherwise use the default set.

Following your suggestion, compiling something with the 'format' and
'bad-case-datum' warnings disabled (but otherwise using the default
warnings) looks something like this:

  (compile x #:opts `(#:warnings
                      ,(lset-difference
                        eq?
                        (or (and=> (memq #:warnings
                                         %auto-compilation-options)
                                   cadr)
                            '())
                        '(format bad-case-datum))))

With my proposal, it looks like this:

  (compile x #:opts '(#:warnings (default no-format no-bad-case-datum)))

Of course, with suitable helper functions, we could make it easier to
construct a desired set of warnings, but again, it still has the
fundamental problem that a centralized list of warnings inhibits users
from adding their own new warning types that can be disabled in the
standard way.

    Thanks,
      Mark



  reply	other threads:[~2012-02-14 16:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-12  3:57 Let's fix how warnings are specified Mark H Weaver
2012-02-14 14:00 ` Ludovic Courtès
2012-02-14 16:56   ` Mark H Weaver [this message]
2012-02-15 22:09     ` Andy Wingo
2012-02-16 21:22     ` Ludovic Courtès
2013-01-16 10:34       ` Andy Wingo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87hayt4alh.fsf@netris.org \
    --to=mhw@netris.org \
    --cc=guile-devel@gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).