help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Declaring a local dynamic variable?


From: Joost Kremers
Subject: Declaring a local dynamic variable?
Date: 20 Sep 2013 09:52:17 GMT
User-agent: slrn/pre1.0.0-18 (Linux)

Hi,

If I purposefully use a local dynamic variable as in:

(defun foo ()
  (let* ((my-counter 0)
         (var (or (bar 'one)
                  (bar 'two)
                  (bar 'three))))
    (do-something-with var)
    (issue-a-message-depending-on-the-value-of my-counter)))

(defun bar (arg)
  (setq my-counter (1+ my-counter))
  (do-something-with arg)
  (and-return-result))

the byte compiler will issue a warning about referring to a free
variable in `bar'. What is the proper way of letting the byte compiler
know that it shouldn't worry about this particular variable, without
silencing it completely? I don't want to disable all warnings, or even
just the warnings about free variables.

Right now, I'm using a `(defvar my-counter)' inside the function
definition of `bar', but that looks a bit strange. Is there a better or
"more proper" way of doing this?

TIA

Joost


-- 
Joost Kremers                                   address@hidden
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)


reply via email to

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