[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Returning variable "references" under lexical binding
From: |
Stefan Monnier |
Subject: |
Re: Returning variable "references" under lexical binding |
Date: |
Mon, 20 May 2013 23:18:42 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
> (defun start-my-timer ()
> (let ((timer (gensym)))
> ;; ... (set timer (make-timer ...)) ...
> timer))
[...]
> (defun cancel-my-timer (timer)
> (cancel-timer (symbol-value timer)))
Why not
(defun start-my-timer ()
(let ((timer (make-timer ...))
...
timer))
(defun cancel-my-timer (timer)
(cancel-timer timer))
> The documenentation for lexical variables cautions against treating them
> as symbols, specifically stating that functions like symbol-value will
> not work.
In your above code, you're not treating variables as symbols.
You're just storing a symbol inside a variable, which is fine.
E.g. a problematic example would have been (set 'timer ...) or
(symbol-value 'timer).
Stefan
- Returning variable "references" under lexical binding, Sean McAfee, 2013/05/20
- Re: Returning variable "references" under lexical binding, Barry Margolin, 2013/05/20
- Re: Returning variable "references" under lexical binding,
Stefan Monnier <=
- Message not available
- Re: Returning variable "references" under lexical binding, Sean McAfee, 2013/05/21
- Re: Returning variable "references" under lexical binding, Stefan Monnier, 2013/05/21
- Re: Returning variable "references" under lexical binding, Barry Margolin, 2013/05/21
- Re: Returning variable "references" under lexical binding, Sean McAfee, 2013/05/21
- Re: Returning variable "references" under lexical binding, Barry Margolin, 2013/05/21
- Re: Returning variable "references" under lexical binding, Sean McAfee, 2013/05/21
- Re: Returning variable "references" under lexical binding, Stefan Monnier, 2013/05/22