[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Any disadvantages of using put/get instead of defvar?
From: |
Stefan Monnier |
Subject: |
Re: Any disadvantages of using put/get instead of defvar? |
Date: |
Thu, 20 Feb 2014 20:40:08 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
> You could also define the variable inside the function, i.e., that's a
> buffer-local counter:
> (defun counter ()
> (defvar counter-var 1)
> (setq-local counter-var (1+ counter-var)))
I'd recommend against it. Its semantics is pretty much the same as
(defun counter ()
(defvar counter-var 1)
(setq-local counter-var (1+ counter-var)))
except that `counter-var' will only be defined after the first call to
`counter'.
And no, it's not buffer-local.
Stefan
- Any disadvantages of using put/get instead of defvar?, Oleh, 2014/02/20
- Re: Any disadvantages of using put/get instead of defvar?, Oleh, 2014/02/21
- Re: Any disadvantages of using put/get instead of defvar?, Tassilo Horn, 2014/02/21
- Re: Any disadvantages of using put/get instead of defvar?, Oleh, 2014/02/21
- Re: Any disadvantages of using put/get instead of defvar?, Andreas Röhler, 2014/02/21
- Re: Any disadvantages of using put/get instead of defvar?, Tassilo Horn, 2014/02/21
- Message not available
- Re: Any disadvantages of using put/get instead of defvar?, Helmut Eller, 2014/02/21