[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Compiler warning for unused local top-level variables
From: |
Ludovic Courtès |
Subject: |
Re: Compiler warning for unused local top-level variables |
Date: |
Mon, 11 Jan 2010 23:00:51 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
Howdy,
Andy Wingo <address@hidden> writes:
> On Mon 11 Jan 2010 02:02, address@hidden (Ludovic Courtès) writes:
[...]
>> - 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.
You mean consider that no variables is unused when a module exports one
or more macros?
I was thinking about somehow “opening” syntax objects.
This expression ‘(define-syntax baz (syntax-rules () ((_) asinh)))’
compiles to:
--8<---------------cut here---------------start------------->8---
(define baz
(apply (@@ (guile) make-syntax-transformer)
(const baz)
(const macro)
[...]
(const #(syntax-object
asinh
((top)
#(ribcage
#(dummy)
#((m69 top))
#("i74"))
--8<---------------cut here---------------end--------------->8---
If we had, say, ‘syntax-object-toplevel?’ to check whether a syntax
object captures a top-level binding, that’d be enough. Then we could
use ‘syntax->datum’ to get the symbol, and voilà.
What am I missing? :-)
Thanks,
Ludo’.