[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Compiler warning for unused local top-level variables

From: Ludovic Courtès
Subject: Compiler warning for unused local top-level variables
Date: Mon, 11 Jan 2010 02:02:26 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)


With the new ‘-Wunused-toplevel’ the compiler warns about unused
module-local top-level variables [0].

It works well, but has the following limitations:

  - Public variables exported with ‘define-public’, ‘export’, or anything
    other than the ‘#:export’ option of ‘define-module’ is considered
    private, and thus possibly misdiagnosed as unused.

    This is because ‘export’ et al. are only evaluated at run-time, not
    at compile-time, unlike ‘define-module’.  This is something we could
    change, though.

  - Local variables used only by a macro are incorrectly flagged as
    unused.  Example:

          (define (bar) 'foo)
          (define-syntax baz
            (syntax-rules () ((_) (bar))))

    Here ‘bar’ is incorrectly flagged as unused.  This is because the
    definition of ‘baz’ expands to ‘(define baz (make-syntax-transformer
    ...))’ and this code doesn’t contain any literal
    ‘(toplevel-ref bar)’.  Instead, the reference to ‘bar’ is buried in
    an opaque syntax object.

    Andy: any idea how to work around this?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]