emacs-devel
[Top][All Lists]
Advanced

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

Re: void variable


From: Stefan Monnier
Subject: Re: void variable
Date: 19 Aug 2004 15:33:53 -0400
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

>     Maybe we could arrange for defvar to burp a warning if the var is
>     currently let-bound?
> That sounds like a good idea.  It should be possible to do this
> by searching the specpdl.

The patch below seems to work well.  Any objection (or suggestion of
a better message)?


        Stefan


--- orig/src/eval.c
+++ mod/src/eval.c
@@ -747,6 +747,20 @@
        XSYMBOL (sym)->constant = 0;
       if (NILP (tem))
        Fset_default (sym, Feval (Fcar (tail)));
+      else
+       { /* Check if there is really a global binding rather than just a let
+            binding that shadows the global unboundness of the var.  */
+         struct specbinding *pdl = specpdl_ptr;
+         while (--pdl >= specpdl)
+           {
+             if (!pdl->func && EQ (pdl->symbol, sym) && EQ (pdl->old_value, 
Qunbound))
+               {
+                 message_with_string ("%s is still globally unbound",
+                                      SYMBOL_NAME (sym), 1);
+                 pdl = specpdl; /* Don'tlook further.  */
+               }
+           }
+       }
       tail = Fcdr (tail);
       tem = Fcar (tail);
       if (!NILP (tem))




reply via email to

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