From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: void variable Date: 19 Aug 2004 15:33:53 -0400 Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Message-ID: References: <410353ED.1090107@math.ku.dk> <4104091E.4040007@math.ku.dk> <200407252046.i6PKkFH29813@raven.dms.auburn.edu> <200407262041.i6QKfFu15523@raven.dms.auburn.edu> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1092944096 28267 80.91.224.253 (19 Aug 2004 19:34:56 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 19 Aug 2004 19:34:56 +0000 (UTC) Cc: larsh@math.ku.dk, Luc Teirlinck , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Aug 19 21:34:46 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BxsgQ-0000Fi-00 for ; Thu, 19 Aug 2004 21:34:46 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1Bxskg-0002c1-PN for ged-emacs-devel@m.gmane.org; Thu, 19 Aug 2004 15:39:10 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1BxskY-0002bF-TR for emacs-devel@gnu.org; Thu, 19 Aug 2004 15:39:02 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1BxskW-0002a7-LL for emacs-devel@gnu.org; Thu, 19 Aug 2004 15:39:01 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BxskW-0002a4-JT for emacs-devel@gnu.org; Thu, 19 Aug 2004 15:39:00 -0400 Original-Received: from [132.204.24.67] (helo=mercure.iro.umontreal.ca) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Bxsfp-0008L6-FY; Thu, 19 Aug 2004 15:34:09 -0400 Original-Received: from asado.iro.umontreal.ca (asado.iro.umontreal.ca [132.204.24.84]) by mercure.iro.umontreal.ca (Postfix) with ESMTP id 46C60B3028A; Thu, 19 Aug 2004 15:33:54 -0400 (EDT) Original-Received: by asado.iro.umontreal.ca (Postfix, from userid 20848) id DFF2B8CA23; Thu, 19 Aug 2004 15:33:53 -0400 (EDT) Original-To: rms@gnu.org In-Reply-To: Original-Lines: 35 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 X-DIRO-MailScanner-Information: Please contact the ISP for more information X-DIRO-MailScanner: Found to be clean X-DIRO-MailScanner-SpamCheck: n'est pas un polluriel, SpamAssassin (score=0, requis 5) X-MailScanner-From: monnier@iro.umontreal.ca X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:26328 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:26328 > 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))