[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to avoid compiler warning `unused lexical variable' for `dolist'
From: |
Emanuel Berg |
Subject: |
Re: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'? |
Date: |
Thu, 07 Jan 2021 11:03:30 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Jean Louis wrote:
> (defun db/table-id-plist (table id pg)
> "Returns plist for table by its table_id"
> (let* ((columns (db/table-columns table pg))
> (sql (db/sql-by-columns table columns id))
> (values (rcd-sql-first sql pg))
> (values (append values nil))
> (length (length columns))
> (plist '()))
> (dotimes (i length plist)
> (setf plist (plist-put plist (intern (elt columns i)) (elt values
> i))))))
>
> What is proper way to avoid this warning in `dolist' or
> `dotimes':
>
> rcd-db.el:841:1: Warning: Unused lexical variable āiā
>
> Declaring variable `i' in `let' before `dolist' or `dotimes'
> did not help.
Right. Let's just say it is a `dotimes' thing, see line
309-310, /usr/local/share/emacs/28.0.50/lisp/subr.el
;; FIXME: This let often leads to "unused var" warnings.
`((let ((,(car spec) ,counter)) ,@(cddr spec))))))
(require 'cl-lib)
(defun db/table-id-plist (table id pg)
"Do something with TABLE, ID and PG."
(let*((cols (db/table-columns table pg))
(sql (db/sql-by-columns table cols id))
(vals (rcd-sql-first sql pg))
(plist) )
(cl-loop for c in cols
for v in vals
do (setf plist (plist-put plist (intern c) v)) )))
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal