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: Philipp Stephani
Subject: Re: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'?
Date: Thu, 7 Jan 2021 12:33:49 +0100

Am Do., 7. Jan. 2021 um 12:15 Uhr schrieb Jean Louis <bugs@gnu.support>:
>
> * 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.

The discussion in that bug implies that it won't get fixed. Probably
we should discourage the three-argument form more strongly, e.g. by
removing it from the documentation and changing the advertised calling
convention.



reply via email to

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