[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: run-with-timer does not display message
From: |
Sebastian Wiesner |
Subject: |
Re: run-with-timer does not display message |
Date: |
Sun, 20 Jul 2014 14:15:19 +0200 |
User-agent: |
KMail/4.13.3 (Linux/3.16.0-0.rc5.git1.1.fc22.x86_64; KDE/4.13.3; x86_64; ; ) |
Am Samstag, 19. Juli 2014, 19:43:16 schrieb Emanuel Berg:
> 2. Interestingly, what I can see, my method, with
> backticks and commas, isn't that "lexical" - because
> then, there, the actual values are inserted?
Note quite. The backquote is “static” in that it captures the *value* of the
variable at the time the backquote is evaluated. “Lexical” binding captures
the *variable itself*.
This makes a difference if the variable is changed after capturing.
Considering the following example:
ELISP> (let ((i 10))
(setq f-lexical (lambda () i))
(setq f-backquote `(lambda () ,i))
(setq i 20))
20 (#o24, #x14, ?\C-t)
ELISP> (funcall f-lexical)
20 (#o24, #x14, ?\C-t)
ELISP> (funcall f-backquote)
10 (#o12, #xa, ?\C-j)
As you can see, changing "i" *after* creating the functions only affects the
closure created by lexical binding. The function created by the backquote is
left untouched.
This specific behaviour is what makes lexical binding special: Capturing
*lexical variables* in closures, as opposed to capturing values (by
backquotes) or just using dynamic variables. You cannot easily and
efficiently emulated this behaviour with macros and backquotes.
- Re: run-with-timer does not display message, (continued)
- Re: run-with-timer does not display message, Thorsten Jolitz, 2014/07/15
- Re: run-with-timer does not display message, Stefan Monnier, 2014/07/18
- Message not available
- Re: run-with-timer does not display message, Emanuel Berg, 2014/07/18
- Re: run-with-timer does not display message, Sebastian Wiesner, 2014/07/19
- Re: run-with-timer does not display message, Eli Zaretskii, 2014/07/19
- Re: run-with-timer does not display message, Stefan Monnier, 2014/07/19
- RE: run-with-timer does not display message, Drew Adams, 2014/07/19
- Message not available
- Re: run-with-timer does not display message, Emanuel Berg, 2014/07/19
- Re: run-with-timer does not display message, Stefan Monnier, 2014/07/19
- Lexical and Dynamic Scope, Robert Thorpe, 2014/07/19
- Re: run-with-timer does not display message,
Sebastian Wiesner <=
- Re: run-with-timer does not display message, Stefan Monnier, 2014/07/21
- Message not available
- Re: run-with-timer does not display message, Emanuel Berg, 2014/07/20
- Re: run-with-timer does not display message, Stefan Monnier, 2014/07/21
- Message not available
- Re: run-with-timer does not display message, Emanuel Berg, 2014/07/21
- Re: run-with-timer does not display message, Stefan Monnier, 2014/07/24
- Message not available
- Re: run-with-timer does not display message, Emanuel Berg, 2014/07/20
- RE: run-with-timer does not display message, Drew Adams, 2014/07/20
- Message not available
- dynamic and lexical scope, attempted summary with example (was: Re: run-with-timer does not display message), Emanuel Berg, 2014/07/20
- Re: dynamic and lexical scope, attempted summary with example, Thien-Thi Nguyen, 2014/07/21
- Re: dynamic and lexical scope, attempted summary with example, Thorsten Jolitz, 2014/07/21