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

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

RE: DynamicBindingVsLexicalBinding


From: Drew Adams
Subject: RE: DynamicBindingVsLexicalBinding
Date: Sun, 13 Oct 2013 09:21:33 -0700 (PDT)

> lexical binding allows you to support closures, and with closures
> you can do cool things.

Yes.  And they remove "funarg" problems.

> with dynamic binding you can do other cool things (you can let-bind
> a variable, then call a function which calls...and the innermost
> function will reference the value you just bound -- so you can pass
> parameters around without actually having to mention them on every
> function call).

Yes.  Which is especially important for a heavily interactive and
customizable program such as Emacs.  Emacs users extend and otherwise
modify or adapt the source code, and they do so sometimes on the fly
and interactively.

And that's not only a good thing instead of a bad thing.  It is
practically the raison d'etre of Emacs: It is a user Lisp environment
(which offers editor/UI objects such as buffers and windows).

> So each of the styles has their own advantage.

Definitely.  Those who imagine that a lexical-only approach, a la
Scheme, would be a better way to go for Emacs are on the wrong track,
IMHO.

> I find that the idea that variables declared specially (e.g. with
> defvar) can be dynamically bound whereas everything else is
> lexically bound by default -- this idea is quite useful.  For if
> you want to dynamically bind something to influence another
> function, you need to know which variables that other function uses
> -- and defvar is a good way to document this.

Yes, again.  Common Lisp showed how to have lexical and dynamic
scope cohabit the same programming language.  Its approach to this is
still a good model to follow.

Now if only Emacs Lisp had good namespace control, like Common-Lisp
packages...



reply via email to

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