emacs-devel
[Top][All Lists]
Advanced

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

Re: Defvaralias and lexical binding


From: Stefan Monnier
Subject: Re: Defvaralias and lexical binding
Date: Sat, 11 Jun 2011 11:58:50 -0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

> Aliases for lexically-bound variables don't behave as I expected them
> to. The 'defvaralias' documentation says that aliased variables "always
> have the same value" (docstring) and that they "always share the same
> value and the same bindings" (Info), which is true for non-void special
> variables, but apparently not for lexically-bound variables or void
> special variables. Here's an IELM session with some examples (with
> lexical-binding enabled):

defvaralias does not work on lexically bound variables.
Indeed (defvaralias <var1> <var2>) declares <var1> as dynamically scoped
but for some reason it currently doesn't do the same with <var2>.
I guess the patch below would fix those problems.


        Stefan


=== modified file 'src/eval.c'
--- src/eval.c  2011-05-31 15:38:34 +0000
+++ src/eval.c  2011-06-11 14:58:03 +0000
@@ -750,6 +750,7 @@
   }
 
   sym->declared_special = 1;
+  XSYMBOL (base_variable)->declared_special = 1;
   sym->redirect = SYMBOL_VARALIAS;
   SET_SYMBOL_ALIAS (sym, XSYMBOL (base_variable));
   sym->constant = SYMBOL_CONSTANT_P (base_variable);




reply via email to

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