From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thierry Volpiatto Newsgroups: gmane.emacs.devel Subject: Re: Possible defvar bug Date: Mon, 18 Feb 2013 16:41:12 +0100 Organization: Emacs Helm Message-ID: <8738wty6hz.fsf@gmail.com> References: <87d2vxr8h6.fsf@thinkpad.tsdh.de> <87obfhy8zc.fsf@gmail.com> <20130218150954.GA4583@acm.acm> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1361202099 20028 80.91.229.3 (18 Feb 2013 15:41:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 18 Feb 2013 15:41:39 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Feb 18 16:42:02 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1U7Sqv-0005e1-JB for ged-emacs-devel@m.gmane.org; Mon, 18 Feb 2013 16:42:01 +0100 Original-Received: from localhost ([::1]:59041 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U7Sqb-000566-Kq for ged-emacs-devel@m.gmane.org; Mon, 18 Feb 2013 10:41:41 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:57258) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U7SqT-000560-9F for emacs-devel@gnu.org; Mon, 18 Feb 2013 10:41:40 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U7SqO-0002IG-C2 for emacs-devel@gnu.org; Mon, 18 Feb 2013 10:41:33 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:39241) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U7SqO-0002Hs-6R for emacs-devel@gnu.org; Mon, 18 Feb 2013 10:41:28 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1U7Sqe-0005RR-0B for emacs-devel@gnu.org; Mon, 18 Feb 2013 16:41:44 +0100 Original-Received: from lbe83-2-78-243-104-167.fbx.proxad.net ([78.243.104.167]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 18 Feb 2013 16:41:43 +0100 Original-Received: from thierry.volpiatto by lbe83-2-78-243-104-167.fbx.proxad.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 18 Feb 2013 16:41:43 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 44 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: lbe83-2-78-243-104-167.fbx.proxad.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.93 (gnu/linux) Cancel-Lock: sha1:5Rdij6na39TlYblug1EK5D7aTss= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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 Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:157132 Archived-At: Alan Mackenzie writes: > On Mon, Feb 18, 2013 at 04:00:28PM +0100, Didier Verna wrote: >> Jambunathan K wrote: > >> > I am certain I don't understand what these paragraphs mean, >> > particularly the second one. >> > lands. > >> > ,---- C-h f >> > | If SYMBOL has a local binding, then this form affects the local >> > | binding. This is usually not what you want. Thus, if you need to >> > | load a file defining variables, with this form or with `defconst' or >> > | `defcustom', you should always load that file _outside_ any bindings >> > | for these variables. (`defconst' and `defcustom' behave similarly in >> > | this respect.) >> > `---- > >> This means that: > >> ELISP> (let ((foo 3)) >> (defvar foo 1) >> (print foo)) >> 3 >> ELISP> foo >> *** Eval error *** Symbol's value as variable is void: foo >> ELISP> > > >> And, no, this is almost never what you want :-) Just like Tassilo >> noticed by accident. > > Why would anybody want to defvar a variable inside a let binding which > also defines it, anyway? It may not be totally invalid, but it's > certainly in breach of good taste. I would argue that the current > behaviour _is_ what is wanted, since it alerts one to a probable error. See also documentation of `require' which should not be used inside `let' bindings for same reasons. -- Thierry Get my Gnupg key: gpg --keyserver pgp.mit.edu --recv-keys 59F29997