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: Jean Louis
Subject: Re: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'?
Date: Thu, 7 Jan 2021 14:12:34 +0300
User-agent: Mutt/2.0 (3d08634) (2020-11-07)

* Philipp Stephani <p.stephani2@gmail.com> [2021-01-07 13:07]:
> Am Do., 7. Jan. 2021 um 08:59 Uhr schrieb Jean Louis <bugs@gnu.support>:
> >
> > (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ā€™
> 
> This is https://debbugs.gnu.org/cgi/bugreport.cgi?bug=16206. tl;dr:
> don't use the three-argument form of `dotimes':
> 
> (dotimes (i length)  ; no `plist' here
>    ...)
> plist

Yes, thank you, that solves the problem.

But it implies that bug should be rather solved as function
description for `dotimes' allows return value as third argument.

This way is upside down, we tell programmers to not use function that
was defined as usable.




reply via email to

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