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:06:07 +0300
User-agent: Mutt/2.0 (3d08634) (2020-11-07)

* Emanuel Berg via Users list for the GNU Emacs text editor 
<help-gnu-emacs@gnu.org> [2021-01-07 13:11]:
> Philipp Stephani wrote:
> 
> > 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
> 
> No length there - there are loops to iterate data structures,
> so no need to measure them first :)

I am sure it can be replaced with better functions. I use `dotimes'
sometimes when I do not know the length of the list to work on. It may
be replaced by other functions or nicer ones.

In regards to third argument, to tell not to use it is not logical as:

dotimes is a Lisp macro in ‘subr.el’.

(dotimes (VAR COUNT [RESULT]) BODY...)

(dotimes (n 10) (setq a n)) => returns nil

(dotimes (n 10 a) (setq a n)) => returns a as 9

So when I need the return value from dotimes, I need it.




reply via email to

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