[Top][All Lists]

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

Lexical bindings (was Re: table.el)

From: Kim F. Storm
Subject: Lexical bindings (was Re: table.el)
Date: 02 Dec 2001 18:40:53 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1.50

Miles Bader <address@hidden> writes:

> Note that lexical binding is _optional_ -- a source file has to have a
> file header that turns it on, like:
> ;;; ... -*- lexical-binding: t -*-

What happens if you inhibit parsing of local variables, i.e. if
enable-local-variables is nil ?

> As Kai says, variable defined via `defvar' will still be bound
> dynamically, even in a source file that uses lexical binding.

If I understand this correctly, `let' and `let*' will use lexical or
dynamic binding depending on the value of `lexical-binding' - and
whether the actual variable already has a dynamic binding from
`defvar' (or `defspecial').  IMHO, this is a mess!

Since I assume that there is no existing emacs lisp code which
depends on lexical scope, I don't see why we have to make such
dramatic - and complicated - changes to the semantics of `let'.

Wouldn't it be much simpler - and easier to understand - simply to add
lexically scoped alternatives to `let' and `let*', e.g. named `local'
and `local*', and then let `let' keep its current semantics?

For example, in the following code, it is clearly indicated that xyz
has lexical scope while abc has dynamic binding:

        (local ((xyx t)) 
          (let ((abc nil))

This would also remove any dependency on whether and how xyz is
already declared, and no longer depends on whether file local
variables are evaluated when the file is loaded.

Kim F. Storm <address@hidden> http://www.cua.dk

reply via email to

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