Opened 8 years ago

Last modified 8 years ago

#922 new enhancement

Add a way to reference variables that does not count as 'using' them

Reported by: fare Owned by:
Priority: minor Milestone:
Component: Compiler Version: trunk
Keywords: ITA Cc:


Dan Weinreb 2008-11-21 14:08:37 EST Note: This enhancement appears to have relatively low benefit and relatively high cost for CCL, so it should be given low priority.

Warnings about ignored variables are useful. Suppose we feel that we'd like to get an ignored variable warning if the variable is ignored other than in logging calls.

We'd like a way to refer to a variable that does not count as a "usage" of the variable, for purposes of figuring out whether to issue a "warning: the variable foo was unused."


(defun do-a-thing (a b c)

(when (> a 3)

(log-warn "category1" "we're doing a thing with ~a ~a ~a" a b c) .. other Lisp code that never uses the variable b ...


We'd like this to say "warning: b was unused".

log-warn is a macro. We can arrange it to expand into something suitable. I am not sure exactly what that would be. In general, when log-warn is used as shown above, there are a bunch of arbitrary Lisp forms, and we don't want to have to code-walk them.

What I think we'd want to do is expand the macro such that each of the forms was wrapped inside a special form meaning "do this, but during compilation, suppress noting that any variables are being 'used'".

Gail Zacharias says: It might be non-trivial for a somewhat stupid reason... Currently the warnings come out of real compiler reference tracking, so you can't really lie - if you don't mark a variable as referenced in pass1, pass2 won't know to allocate a location for it, etc. The obvious solution is to add a parallel flag, just for the warnings, that's usually the same as the real one but can be manipulated however we want because it's not used by the code generator. Unfortunately, at first glance it looks to me like we might be out of bits in the word that holds the per-variable flags, which probably brings it out of realm of a couple hours into possibly couple days.

NB: This was ITA Bug 51375.

Change History (1)

comment:1 Changed 8 years ago by gz

  • Keywords ITA added
Note: See TracTickets for help on using tickets.