From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sebastian Wiesner Newsgroups: gmane.emacs.help Subject: Re: run-with-timer does not display message Date: Sun, 20 Jul 2014 14:15:19 +0200 Message-ID: <2499282.TBjfJc2tWs@lunaryorn-fedora> References: <878unputvv.fsf@debian.uxu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1405858557 20604 80.91.229.3 (20 Jul 2014 12:15:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 20 Jul 2014 12:15:57 +0000 (UTC) Cc: Emanuel Berg To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Jul 20 14:15:50 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1X8q1t-00060S-Hl for geh-help-gnu-emacs@m.gmane.org; Sun, 20 Jul 2014 14:15:49 +0200 Original-Received: from localhost ([::1]:57567 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X8q1s-0000bh-Qm for geh-help-gnu-emacs@m.gmane.org; Sun, 20 Jul 2014 08:15:48 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42817) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X8q1c-0000aa-1E for help-gnu-emacs@gnu.org; Sun, 20 Jul 2014 08:15:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X8q1V-0003IF-FM for help-gnu-emacs@gnu.org; Sun, 20 Jul 2014 08:15:31 -0400 Original-Received: from vega.uberspace.de ([95.143.172.245]:50125) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X8q1U-0003Hj-Sj for help-gnu-emacs@gnu.org; Sun, 20 Jul 2014 08:15:25 -0400 Original-Received: (qmail 30302 invoked from network); 20 Jul 2014 12:15:22 -0000 Original-Received: from localhost (HELO lunaryorn-fedora.localnet) (127.0.0.1) by vega.uberspace.de with SMTP; 20 Jul 2014 12:15:22 -0000 User-Agent: KMail/4.13.3 (Linux/3.16.0-0.rc5.git1.1.fc22.x86_64; KDE/4.13.3; x86_64; ; ) In-Reply-To: <878unputvv.fsf@debian.uxu> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 95.143.172.245 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:98818 Archived-At: 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 =E2=80=9Cstatic=E2=80=9D in that it captu= res the *value* of the=20 variable at the time the backquote is evaluated. =E2=80=9CLexical=E2=80= =9D binding captures=20 the *variable itself*. This makes a difference if the variable is changed after capturing. =20= 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 affect= s the=20 closure created by lexical binding. The function created by the backqu= ote is=20 left untouched. This specific behaviour is what makes lexical binding special: Capturi= ng=20 *lexical variables* in closures, as opposed to capturing values (by=20 backquotes) or just using dynamic variables. You cannot easily and=20 efficiently emulated this behaviour with macros and backquotes.