|
From: | Emanuel Berg |
Subject: | Re: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'? |
Date: | Fri, 08 Jan 2021 02:12:21 +0100 |
User-agent: | Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Jean Louis wrote: >> Same as for any other place where you might declare >> a variable that you don't actually use: make sure the var's >> name starts with an underscore. This tells the compiler >> that you're aware of the fact the var is not used (but >> still want this variable there for some reason; e.g. >> in dotimes and dolist you don't have the choice not to put >> a variable there). >> >> Traditionally for `dotimes`, I'd then use `_` as the >> variable name unless I really want to give a hint to the >> reader about what kind of things I'm counting like (dotimes >> (_column-nb ...) ...). > > That also sounds like workaround around the real problem. > In `dotimes' I do use the VAR counted. It is not same as > (let ((_ (execute some program without)))) But is this really a workaround in your case? Because you _do_ use it! (dolist (_ignored-var '(a b c)) (message "%s" _ignored-var) ) geh.el:257:1: Warning: variable ‘_ignored-var’ not left unused See? Sometimes the byte-compiler gets it right! :) -- underground experts united http://user.it.uu.se/~embe8573 https://dataswamp.org/~incal
[Prev in Thread] | Current Thread | [Next in Thread] |