Hrvoje Niksic wrote:
> Olivier> I think that lexical scoping would make a huge
difference
> Olivier> by allowing much tighter optimizations of the compiled
> Olivier> code.
>
> It occured to me yesterday that perhaps instead of changing the `let'
> and `let*' into lexical versions, the `lexical-let' from `cl' ought
> to be recoded in C, so that it won't have to do the `aref' it does
> now...
No cigar. Aside from the fact that writing `lexical-let' and
`lexical-let*' is incredibly ugly, there are other variable-creators
that will have to be turned to lexical scope for our scheme to work
correctly, such as function arguments and condition-case.
Sure, but how much code requires function arguments to be dynamically
scoped? I'm sure that there's plenty of code which uses e.g.
(let ((case-fold-search t)) ...
but I would have thought that
(defun foo (case-fold-search) ...
was substantially less common.
Aside from any performance implications, dynamic scope also introduces
the possibility of accidentally binding a global variable which is
referenced by a called function. It's not as if elisp uses the *foo*
convention for special variables.
--
Glynn Clements <glynn(a)sensei.co.uk>