On Mon 11 Jan 2010 02:02, l...@gnu.org (Ludovic Courtès) writes:

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

Cool!

>   - 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.

I see you've fixed this already, cool.

>   - 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?

No, I don't think it's possible to work around this. At least, nothing
comes to mind. You could disable the check if a module exports macros.
This seems fundamental in some way.

As an example:

  (define-syntax baz
    (lambda (x)
      #`(,(call-with-input-file "/tmp/foo" read))))

You really can do any kind of computation at macro-expansion time.

Regards,

Andy
-- 
http://wingolog.org/


Reply via email to