What is "Unused variable G**** in anonymous function"?
Asked Answered
C

1

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.

Chelseachelsey answered 14/8, 2013 at 10:24 Comment(0)
C
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.

Caudell answered 14/8, 2013 at 10:34 Comment(2)
(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!Chelseachelsey
@Chelseachelsey For easier reading, you might try (pprint (macroexpand '(loop ...))). I did that with the code you pasted, and got: 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.)Censurable

© 2022 - 2024 — McMap. All rights reserved.