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: Fri, 8 Jan 2021 07:09:44 +0300
User-agent: Mutt/2.0 (3d08634) (2020-11-07)

* Stefan Monnier <monnier@iro.umontreal.ca> [2021-01-08 06:41]:
> > (defun pct-plus-times (amount percent times)
> >   "Return AMOUNT increased for PERCENT for number of TIMES."
> >   (dotimes (var times amount)
> >     (setq amount (pct-plus amount percent))))
> >
> > And I see that `var' is unused there. I have never used those
> > functions in a package so there were no warnings.
> 
> You can eliminate the warning as follows:
> 
>     (defun pct-plus-times (amount percent times)
>       "Return AMOUNT increased for PERCENT for number of TIMES."
>       (dotimes (var times)
>         (setq amount (pct-plus amount percent)))
>       amount)
> 
> No need to resort to `while`.

To me that means that I need to use workaround because `dotimes' does
not work well as described in docstring. I need to remember something
that is nowhere documented.

Either compiler warning is wrong, or docstring is wrong. One of those
shall be improved.

Users or programmers shall not be directed to avoid using function
which is described how to be used in their documentation.

Isn't it? No logic there for me.



reply via email to

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