help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: run-with-timer does not display message


From: Stefan Monnier
Subject: Re: run-with-timer does not display message
Date: Mon, 21 Jul 2014 09:26:32 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux)

> This specific behaviour is what makes lexical binding special:  Capturing
> *lexical variables* in closures, as opposed to capturing values (by
> backquotes)

While this is used occasionally, most uses of lexical-scoping don't care
about this "feature".  E.g. *all* uses of lexical scoping in the ML
family of languages (which don't have the equivalent of `setq').

> or just using dynamic variables.  You cannot easily and
> efficiently emulated this behaviour with macros and backquotes.

As mentioned in another message, the byte-compiler faces the same
problem.  And the way it solves it can be applied to backquoted lambdas
just as easily: just replace the variable with a cons cell whose `car'
contains the value.

IOW the byte-compiler will generate almost 100% exactly the same code for

   (let ((i 10))
     (setq f-lexical (lambda () i))
     (setq i 20))

as for

   (let ((i (list 10)))
     (setq f-lexical (lambda () (car i)))
     (setcar i 20))

and of course you can get the same result with backquote:

   (let ((i (list 10)))
     (setq f-lexical `(lambda () (car ',i)))
     (setcar i 20))


-- Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]