[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Any disadvantages of using put/get instead of defvar?
From: |
Tassilo Horn |
Subject: |
Re: Any disadvantages of using put/get instead of defvar? |
Date: |
Fri, 21 Feb 2014 12:49:22 +0100 |
User-agent: |
Gnus/5.13001 (Ma Gnus v0.10) Emacs/24.3.50 (gnu/linux) |
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> 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'.
Sure (I guess you mean with the defvar before the defun), but Oleh's
goal was not to have the variable and the function separated.
> And no, it's not buffer-local.
Well, it becomes buffer-local as soon as someone calls `counter'.
Bye,
Tassilo
- 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
- Re: Any disadvantages of using put/get instead of defvar?, Sebastian Wiesner, 2014/02/21