6

I don't know if it is implementation dependent. Just in case it matters, I'm using Corman Lisp 3.0

When I do something like this:

(loop for v being the hash-values of *my-hash-table*
  when (> v 1) sum v)

I get two warnings:

;;; Warning: Unused variable G9063 in anonymous function
;;; Warning: Unused variable G9062 in anonymous function

With the number of G changing every time.

The result is correct though. What do they mean? Why do they appear? I suppose there might be some kind of loop syntax misuse, which leads to these warnings, but I fail to see it.

akalenuk
  • 3,815
  • 4
  • 34
  • 56

1 Answers1

6

Corman Lisp hasn't been updated for years. The G* unused variables are probably gensyms in the macro expansion of loop. Try

(macroexpand '(loop ...))

to see what these variables store.

acelent
  • 7,965
  • 21
  • 39
  • `(LET ((#:G9003 NIL) (V NIL) (#:G9000 WORD-COUNT) (#:G9002 NIL)) (WITH-HASH-TABLE-ITERATOR (#:G9001 #:G9000) (LET ((#:G9004 0)) (DECLARE (TYPE NUMBER #:G9004)) (BLOCK NIL (LOOP::LOOP-BODY NIL (NIL NIL (WHEN (NOT (MULTIPLE-VALUE-SETQ (#:G9003 #:G9002 V) (#:G9001))) (GO LOOP::END-LOOP)) NIL) ((IF (> V 1) (SETQ #:G9004 (+ #:G9004 V)))) (NIL NIL (WHEN (NOT (MULTIPLE-VALUE-SETQ (#:G9003 #:G9002 V) (#:G9001))) (GO LOOP::END-LOOP)) NIL) ((RETURN-FROM NIL #:G9004)))))))` It is little hard to read, but I guess G9002 and G9003 is what I'm looking for. It makes sense now, thanks! – akalenuk Aug 14 '13 at 11:10
  • 1
    @akalenuk For easier reading, you might try `(pprint (macroexpand '(loop ...)))`. I did that with the code you pasted, and got: http://paste.lisp.org/display/138466 (I had to change some of the symbols, e.g., `loop::end-loop` to `loop\:\:end-loop` since SBCL doesn't have a `loop` package, but it's basically the same.) – Joshua Taylor Aug 14 '13 at 13:41