Howdy, Andy Wingo <wi...@pobox.com> writes:
> On Mon 11 Jan 2010 02:02, l...@gnu.org (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’.