emacs-devel
[Top][All Lists]
Advanced

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

Re: Lexical binding -- do we really need it?


From: Miles Bader
Subject: Re: Lexical binding -- do we really need it?
Date: 10 Dec 2001 10:27:30 +0900

Richard Stallman <address@hidden> writes:
> If it is just a matter of efficiency, then the question is,
> how much more efficient does it make Emacs Lisp to do this?
> Have you measured it?

It's not just a matter of effiency; I think lexical binding will result
in fewer odd bugs, because its behavior can be less `surprising'.  For
instance, a problem that has caught me a few times is when I've defined
a function that accepts a function as an argument, like

   (defun foo (... fun) ..... (funcall fun) ...)

and FUN tried to use a variable from the context in which was created,
which happened to have the same name as some local variable in `foo'.
The result is obvious.  It's easy to (mostly) work around this problem
when using dynamic binding, by being careful to give foo's local
variables odd names that probably won't conflict, but the programmer has
to think about it.

As for speed, I timed a simple test function that has a loop containing
some bindings and some arithmetic (unfortunately the file with the test
function is a home, and I'm at work right now), and the results were
dynamic-binding = 40s, lexical-binding = 27s.

> I don't think it is worth while working on optimization in the Emacs
> Lisp compiler.

I wasn't suggesting that we do so; however if someone wants to do it,
lexical binding will make the job easier (or in many cases, possible).

-Miles
-- 
Somebody has to do something, and it's just incredibly pathetic that it
has to be us.  -- Jerry Garcia



reply via email to

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