unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: guile-devel@gnu.org
Cc: guix-devel@gnu.org, "Ludovic Courtès" <ludo@gnu.org>
Subject: [PATCH 0/3] Add '-Wunused-module'
Date: Sun, 12 Feb 2023 00:32:31 +0100	[thread overview]
Message-ID: <20230211233234.14425-1-ludo@gnu.org> (raw)
In-Reply-To: <20230203181126.5ee4003c@tachikoma.lepiller.eu>

Hello Guilers!

Following a discussion started at the Guix Days and continued online¹,
it seems we could benefit from a compiler warning for unused modules,
and this is what this patch does.

The new ‘-Wunused-module’ warning is enabled at ‘-W2’ only.  The main
reason for not enabling it at ‘-W1’ is that in the case of modules used
at macro-expansion time only, such as (srfi srfi-26), it cannot
determine whether a module is definitely unused.  In this case, the
compiler reports the module as “possibly unused”, and it is up to the
programmer to check that claim.

Currently we cannot do any better because warnings operate at the
tree-il, after macro expansion, and there’s nothing indicating whether a
piece of code results from macro expansion.

There’s also the rare case of modules imported for their side effects,
not for their bindings, and that should be kept even if seemingly
“unused”.  One example might be the use of (rnrs bytevectors) in (rnrs
io ports).  But again, that’s super unusual.

Anyway, it’s pretty useful already and has allowed me to trim imports in
Guile modules.

Thoughts?

Ludo’.

¹ https://lists.gnu.org/archive/html/guix-devel/2023-02/msg00028.html

Ludovic Courtès (3):
  Add -Wunused-module.
  Add 'record-case' to '.dir-locals.el'.
  Remove unnecessary module imports.

 .dir-locals.el                         |   1 +
 NEWS                                   |  17 +++
 module/ice-9/copy-tree.scm             |   1 -
 module/ice-9/eval-string.scm           |   1 -
 module/ice-9/getopt-long.scm           |   1 -
 module/ice-9/poll.scm                  |   1 -
 module/ice-9/popen.scm                 |   1 -
 module/ice-9/sandbox.scm               |   1 -
 module/ice-9/threads.scm               |   1 -
 module/language/tree-il/analyze.scm    | 138 +++++++++++++++++++++++-
 module/language/tree-il/fix-letrec.scm |   4 -
 module/sxml/apply-templates.scm        |   2 -
 module/sxml/simple.scm                 |   1 -
 module/system/base/message.scm         |  11 +-
 module/system/base/types.scm           |   1 -
 module/system/repl/command.scm         |   3 -
 module/system/repl/common.scm          |   2 -
 module/system/repl/coop-server.scm     |   1 -
 module/system/repl/debug.scm           |   6 --
 module/system/repl/error-handling.scm  |   1 -
 module/system/repl/repl.scm            |   4 -
 module/system/repl/server.scm          |   1 -
 module/system/vm/assembler.scm         |   2 -
 module/system/vm/disassembler.scm      |   2 -
 module/system/vm/dwarf.scm             |   2 -
 module/system/vm/elf.scm               |   2 -
 module/system/vm/frame.scm             |   2 -
 module/system/vm/inspect.scm           |   5 -
 module/system/vm/linker.scm            |   2 -
 module/system/vm/program.scm           |   1 -
 module/system/vm/trace.scm             |   3 -
 module/system/vm/trap-state.scm        |   1 -
 module/system/vm/traps.scm             |   2 -
 module/system/xref.scm                 |   1 -
 module/texinfo/indexing.scm            |   1 -
 module/texinfo/plain-text.scm          |   3 -
 module/texinfo/reflection.scm          |   2 -
 module/texinfo/string-utils.scm        |   2 -
 module/web/client.scm                  |   3 -
 module/web/http.scm                    |   2 -
 module/web/request.scm                 |   1 -
 module/web/response.scm                |   2 -
 test-suite/tests/tree-il.test          | 141 ++++++++++++++++++++++++-
 43 files changed, 305 insertions(+), 77 deletions(-)


base-commit: 9d339ea1a95c3b2d04a88aa6b116f997349fc4f4
-- 
2.39.1




       reply	other threads:[~2023-02-11 23:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20230203181126.5ee4003c@tachikoma.lepiller.eu>
2023-02-11 23:32 ` Ludovic Courtès [this message]
2023-02-11 23:32   ` [PATCH 1/3] Add -Wunused-module Ludovic Courtès
2023-02-11 23:32   ` [PATCH 2/3] Add 'record-case' to '.dir-locals.el' Ludovic Courtès
2023-02-11 23:32   ` [PATCH 3/3] Remove unnecessary module imports Ludovic Courtès
2023-02-12 18:14   ` [PATCH 0/3] Add '-Wunused-module' Jan Nieuwenhuizen
2023-02-20 10:51     ` Ludovic Courtès
2023-02-24 16:00     ` Ludovic Courtès

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=20230211233234.14425-1-ludo@gnu.org \
    --to=ludo@gnu.org \
    --cc=guile-devel@gnu.org \
    --cc=guix-devel@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).