help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to avoid compiler warning `unused lexical variable' for `dolist'


From: Robert Thorpe
Subject: Re: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'?
Date: Fri, 08 Jan 2021 05:38:31 +0000

I'm still struggling to see how this isn't a bug.

Here is the original code that Jean Louis posted:

> (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))))))
 
And here is the original warning:

> rcd-db.el:841:1: Warning: Unused lexical variable ā€˜iā€™

Jean Louis actually is using the variable i, it's not unused.

You could argue that the warning should be "The three element version of
dotimes is discouraged".  But I can't see how you can argue that the
warning is right, since i is used.

BR,
Robert Thorpe



reply via email to

[Prev in Thread] Current Thread [Next in Thread]