vseloved / rutils

Radical Utilities for Common Lisp
Other
246 stars 36 forks source link

dotable _ weirdness #60

Open slyrus opened 3 years ago

slyrus commented 3 years ago

I haven't looked at the expanded code yet, but when I try to load hash-set.lisp I get warnings of the following sort:

; processing (DEFUN |INTER#| ...)

; file: /home/sly/quicklisp/dists/quicklisp/software/rutils-20201220-git/core/hash-set.lisp
; in: DEFUN |INTER#|
;     (RUTILS.HASH-TABLE:DOTABLE (RUTILS.HASH-SET::ITEM RUTILS.HASH-SET::_
;                                 RUTILS.HASH-SET::SET1)
;       (WHEN (GETHASH RUTILS.HASH-SET::ITEM RUTILS.HASH-SET::SET2)
;         (RUTILS.HASH-SET:|ADD#| RUTILS.HASH-SET::ITEM SET)))
; --> LET BLOCK ETYPECASE LET COND IF PROGN MAPHASH LET* 
; ==>
;   (SB-KERNEL:%COERCE-CALLABLE-TO-FUN
;    (LAMBDA (RUTILS.HASH-SET::ITEM RUTILS.HASH-SET::_)
;      (DECLARE (IGNORE RUTILS.BIND:_))
;      (WHEN (GETHASH RUTILS.HASH-SET::ITEM RUTILS.HASH-SET::SET2)
;        (RUTILS.HASH-SET:|ADD#| RUTILS.HASH-SET::ITEM SET))))
; 
; caught STYLE-WARNING:
;   IGNORE declaration for an unknown variable: _
; 
; caught STYLE-WARNING:
;   The variable _ is defined but never used.

This suggests that the scope of _ is somehow wrong.

mirkov commented 2 years ago

I have a similar issue. I use _ in bind and get the same warning. I imported _, and also used rutils:_, and none helped.

Macro-expanding, I don't see code dealing with _

I looked at the source code, and something like that should happen. If I have time, I will try to trace the issue. No promises.

Note that I have raised a related issue that was closed as resolved.

Right now I am drawing a blank on what I could be doing wrong again. Let me think a bit about this.

jcguu95 commented 2 months ago

I can reproduce a similar issue on version 5.2.1 by


(let ((rez ()))
  (dotable (k _ #h(1 :foo 2 :bar) rez)
    (when (oddp k)
      (push _ rez))))

Notice that the issue would not happen if _ is replaced to v, vv, apple.

jcguu95 commented 2 months ago

Ah, actually, this is a non-issue. The symbol _ is deliberately ignored (c.f. search for _ in the tutorial).

That means if you write (dotable (k _ #h(..).., you should not use _ later in the body.

I suggest to close this issue.