[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to avoid compiler warning `unused lexical variable' for `dolist'
From: |
Leo Butler |
Subject: |
Re: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'? |
Date: |
Sat, 09 Jan 2021 07:15:00 -0600 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) |
Stefan,
I wonder why the lexical-binding version of dotimes is not implemented
like:
#+begin_src emacs-lisp
(let* ((start 0) (end (nth 1 spec)) (counter (gensym))
(body (subst counter (car spec) body)))
`(let ((,counter ,start))
(while (< ,counter ,end)
,@body
(setq ,counter (1+ ,counter)))
,@ (cddr spec))))
#+end_src
I am familiar with the comment in subr.el about uninterned symbols, but
TBH, I don't have a sense of where the performance penalty might be
of any significant size.
Leo
Jean Louis <bugs@gnu.support> writes:
> ********************************************************
> Caution: This message was sent from outside the University of Manitoba.
> ********************************************************
>
> * Stefan Monnier <monnier@iro.umontreal.ca> [2021-01-08 10:16]:
>> > Only it is not relevant to macro or function that is documented to
>> > work, but then again it gives warnings for `n' and not for `return' as
>> > in above example.
>>
>> Not sure what you mean by "documented", but `C-h f dotimes` says:
>>
>> dotimes is a Lisp macro in ‘subr.el’.
>>
>> (dotimes (VAR COUNT [RESULT]) BODY...)
>>
>> Probably introduced at or before Emacs version 21.1.
>>
>> Loop a certain number of times.
>> Evaluate BODY with VAR bound to successive integers running from 0,
>> inclusive, to COUNT, exclusive.
>>
>> Finally RESULT is evaluated to get the return value (nil if
>> RESULT is omitted). Using RESULT is deprecated, and may result
>> in compilation warnings about unused variables.
>>
>> Notice the last sentence.
>
> Now I do notice it.
>
> I do switch to `while' and mapping functions rather.
>
> Jean
- Re: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'?, (continued)
- Re: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'?, tomas, 2021/01/08
- Re: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'?, Emanuel Berg, 2021/01/08
- Re: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'?, tomas, 2021/01/08
- Re: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'?, Philipp Stephani, 2021/01/08
- Re: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'?, Emanuel Berg, 2021/01/08
- Re: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'?, Emanuel Berg, 2021/01/08
- Re: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'?, Philipp Stephani, 2021/01/08
- Re: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'?, Emanuel Berg, 2021/01/08
- Re: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'?, tomas, 2021/01/08
- Re: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'?, Jean Louis, 2021/01/09
- Re: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'?,
Leo Butler <=
- Re: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'?, Philipp Stephani, 2021/01/09
- Re: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'?, Leo Butler, 2021/01/09
- Re: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'?, Stefan Monnier, 2021/01/09
- Re: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'?, Leo Butler, 2021/01/11
- Re: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'?, Stefan Monnier, 2021/01/11
- RE: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'?, Drew Adams, 2021/01/07
- Re: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'?, Stefan Monnier, 2021/01/07
- RE: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'?, Drew Adams, 2021/01/08
- How to get plist properties list?, Jean Louis, 2021/01/07
- Re: How to get plist properties list?, Stefan Monnier, 2021/01/08