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

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

Re: Declaring a local dynamic variable?


From: Stefan Monnier
Subject: Re: Declaring a local dynamic variable?
Date: Tue, 24 Sep 2013 17:34:38 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

>>> If I purposefully use a local dynamic variable as in:
>> Use (defvar my-counter) at the file's top-level to indicate that this
>> variable is used in a way that relies on dynamic scoping.
> Is that preferable to putting the defvar inside the function definition
> where the variable is used dynamically?

Depends, but usually I recommend you put the defvar at top-level,
otherwise you have to put it at various places (everywhere it's
let-bound and everywhere where it's referenced).

Also, I strongly recommend those dynamically-scoped vars use a package
prefix, just like global variables (since they are fundamentally global
variables).


        Stefan


reply via email to

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