all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Barry Margolin <barmar@alum.mit.edu>
To: help-gnu-emacs@gnu.org
Subject: Re: Declaring a local dynamic variable?
Date: Sat, 21 Sep 2013 07:31:11 -0400	[thread overview]
Message-ID: <barmar-6F43FF.07311021092013@news.eternal-september.org> (raw)
In-Reply-To: mailman.2622.1379742443.10748.help-gnu-emacs@gnu.org

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1948 bytes --]

In article <mailman.2622.1379742443.10748.help-gnu-emacs@gnu.org>,
 Andreas Röhler <andreas.roehler@easy-emacs.de> wrote:

> Am 20.09.2013 22:59, schrieb Barry Margolin:
> > In article <mailman.2578.1379694764.10748.help-gnu-emacs@gnu.org>,
> >   Andreas Röhler <andreas.roehler@easy-emacs.de> wrote:
> >
> >> Am 20.09.2013 17:10, schrieb Barry Margolin:
> >>> In article <mailman.2569.1379688787.10748.help-gnu-emacs@gnu.org>,
> >>>    Andreas Röhler <andreas.roehler@easy-emacs.de> 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? 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.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


  parent reply	other threads:[~2013-09-21 11:31 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-20  9:52 Declaring a local dynamic variable? Joost Kremers
2013-09-20 12:30 ` Stefan Monnier
2013-09-20 14:54   ` Andreas Röhler
     [not found]   ` <mailman.2569.1379688787.10748.help-gnu-emacs@gnu.org>
2013-09-20 15:10     ` Barry Margolin
2013-09-20 16:34       ` Andreas Röhler
     [not found]       ` <mailman.2578.1379694764.10748.help-gnu-emacs@gnu.org>
2013-09-20 20:59         ` Barry Margolin
2013-09-21  5:49           ` Andreas Röhler
2013-09-23 16:19           ` Joost Kremers
     [not found]           ` <mailman.2622.1379742443.10748.help-gnu-emacs@gnu.org>
2013-09-21 11:31             ` Barry Margolin [this message]
2013-09-21 13:32               ` Andreas Röhler
     [not found]               ` <mailman.2638.1379770251.10748.help-gnu-emacs@gnu.org>
2013-09-22  3:49                 ` Barry Margolin
2013-09-23 16:26             ` Joost Kremers
2013-09-23 21:17               ` Barry Margolin
2013-09-23 22:14                 ` Joost Kremers
2013-09-24  0:03                   ` Barry Margolin
2013-09-25  8:58                     ` Joost Kremers
2013-09-22 17:11 ` Pascal J. Bourguignon
2013-09-23 16:17   ` Joost Kremers
2013-09-24 21:40   ` Stefan Monnier
2013-11-02 23:56   ` WJ
2013-11-03  1:42   ` WJ
     [not found] ` <mailman.2566.1379680283.10748.help-gnu-emacs@gnu.org>
2013-09-23 16:11   ` Joost Kremers
2013-09-24 21:34     ` Stefan Monnier
2013-09-25  5:52       ` Andreas Röhler
2013-09-25  7:24         ` Stefan Monnier
2013-09-25  8:43       ` Joost Kremers
2013-09-25 12:26         ` Stefan Monnier
2013-10-12 16:54           ` Andreas Röhler
     [not found]           ` <mailman.3886.1381596756.10748.help-gnu-emacs@gnu.org>
2013-10-12 21:25             ` Kai Grossjohann
2013-10-13  8:12               ` Andreas Röhler
2013-10-13 13:37                 ` Stefan Monnier
2013-10-13 17:41                   ` Andreas Röhler
2013-10-13 19:56                     ` Kai Großjohann
     [not found]         ` <mailman.2843.1380112007.10748.help-gnu-emacs@gnu.org>
2013-09-25 15:46           ` Barry Margolin
2013-09-25 18:53             ` Stefan Monnier
2013-09-27  9:53               ` Andreas Röhler
2013-09-27 13:15                 ` Stefan Monnier
     [not found]               ` <mailman.2982.1380275511.10748.help-gnu-emacs@gnu.org>
2013-09-27 14:31                 ` Barry Margolin
2013-09-27 18:48                   ` Andreas Röhler
     [not found]                   ` <mailman.3016.1380307597.10748.help-gnu-emacs@gnu.org>
2013-09-27 20:18                     ` Pascal J. Bourguignon
2013-09-27 23:57                       ` Stefan Monnier
2013-09-28  6:20                       ` Andreas Röhler
2013-09-28  6:24                         ` W. Greenhouse
2013-09-28  6:50                           ` Andreas Röhler
2013-09-28  7:21                             ` W. Greenhouse
     [not found]             ` <mailman.2873.1380135245.10748.help-gnu-emacs@gnu.org>
2013-09-26  0:06               ` Barry Margolin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=barmar-6F43FF.07311021092013@news.eternal-september.org \
    --to=barmar@alum.mit.edu \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.