From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?ISO-8859-15?Q?Andreas_R=F6hler?= Newsgroups: gmane.emacs.help Subject: Re: Declaring a local dynamic variable? Date: Sat, 21 Sep 2013 15:32:42 +0200 Message-ID: <523D9FFA.7080501@easy-emacs.de> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1379770258 24208 80.91.229.3 (21 Sep 2013 13:30:58 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 21 Sep 2013 13:30:58 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Sep 21 15:31:01 2013 Return-path: Envelope-to: geh-help-gnu-emacs@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 1VNNH2-0006vh-O4 for geh-help-gnu-emacs@m.gmane.org; Sat, 21 Sep 2013 15:31:00 +0200 Original-Received: from localhost ([::1]:60226 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VNNH2-0003Jf-82 for geh-help-gnu-emacs@m.gmane.org; Sat, 21 Sep 2013 09:31:00 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59303) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VNNGn-0003JN-00 for help-gnu-emacs@gnu.org; Sat, 21 Sep 2013 09:30:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VNNGh-0006qo-MF for help-gnu-emacs@gnu.org; Sat, 21 Sep 2013 09:30:44 -0400 Original-Received: from moutng.kundenserver.de ([212.227.126.171]:60759) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VNNGh-0006qg-CY for help-gnu-emacs@gnu.org; Sat, 21 Sep 2013 09:30:39 -0400 Original-Received: from purzel.sitgens (brln-4dba07dd.pool.mediaWays.net [77.186.7.221]) by mrelayeu.kundenserver.de (node=mreu1) with ESMTP (Nemesis) id 0MZQZl-1VbS8e2A97-00Ky9m; Sat, 21 Sep 2013 15:30:37 +0200 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 In-Reply-To: X-Provags-ID: V02:K0:ZWEbhSvNgj/YsK3JdDlNknFqCJkg7+4JwTHdUv3mz4O 0eXPei1Q/A+RlW32lRn+X5hg0CDZmBzVn2XvHeVP7Qr0MI/d0T M+mhtpasicEx4dCLKp5WV+pB2jurLC4ubZcdSL7iVA+l15lu+N oHba72PFyNcW/ArslQyIhhsWOVnANM/Lw8GLid5aRpanp75d3k r+ItaC27RH9vSxFg2Ml3PkV7Kqjb2oVc5OAfL+WRcPLj0kb7Ra xv4XPmw6jSPk7oRZ8VlMhvyLckK0lwWhejB2DqpM99WhjChl++ +JjwLo/eWPVRsnO+tL0oEQuUx3zwMyaibdsaOfyDEIkqdIDcUQ gPRb4CnilrjHa5vIRT80= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 212.227.126.171 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:93492 Archived-At: Am 21.09.2013 13:31, schrieb Barry Margolin: > In article , > Andreas Röhler wrote: > >> Am 20.09.2013 22:59, schrieb Barry Margolin: >>> In article , >>> Andreas Röhler wrote: >>> >>>> Am 20.09.2013 17:10, schrieb Barry Margolin: >>>>> In article , >>>>> Andreas Röhler wrote: >>>>> >>>>>> Am 20.09.2013 14:30, schrieb Stefan Monnier: >>>>>>>> If I purposefully use a local dynamic variable as in: >>>>>>> >>>>>>> Use (defvar my-counter) at the file's top-level to indicate that this >>>>>>> variable is used in a way that relies on dynamic scoping. >>>>>> >>>>>> A need to write code just to silence compiler warnings? >>>>>> Emacs could do better. >>>>> >>>>> Other than "code", what would you suggest? >>>> >>>> In the precise case: just drop that warning. >>>> >>>> In a wider sense, IMO a modular approach is better. >>>> Restrict compiler warnings to obvious errors, don't mix style questions in. >>> >>> This isn't a style warning. Often the reason is mistyping a local >>> variable name. >>> >>> (let ((foobar ...)) >>> ... >>> (blah fobar) >>> ...) >>> >> >> This is another case. IIUC there was nothing wrong with the OP's example. > > But how is the compiler supposed to know the difference? A code-checker might look up, if a variable is defined. If our eyes may notice the difference, why a checker should not? Either it > always warns, and generate false positives when you compile the user of > a variable before loading the defvar, or never warns and there are false > negatives when the user makes a typo. > > In this case, false positives are the better option, since you can > easily silence them by adding a defvar. If the warning were removed, > there's no way to get the warning when you actually do make a typo. > Unfortunatly it's not the only occassion. Compiler message is cluttered with false positives that way.