From: "Drew Adams" <drew.adams@oracle.com>
To: "'Stefan Monnier'" <monnier@iro.umontreal.ca>, <help-gnu-emacs@gnu.org>
Subject: RE: Avoiding 'reference to free variable' warnings whilesplittingelisp source files
Date: Sat, 23 Mar 2013 11:23:23 -0700 [thread overview]
Message-ID: <34FC3C03F8024543AA455B46C30A3AE7@us.oracle.com> (raw)
In-Reply-To: <jwvip4iqb1i.fsf-monnier+gmane.emacs.help@gnu.org>
> > This form defines `foo' but does not initialize it:
> > (defvar foo) => foo
>
> Oops that should be "declares `foo'" since it doesn't define it.
It does (Emacs, so far) or it doesn't (Stefan). It depends on what one means by
"defining".
The node (elisp) `Defining Variables' starts by saying what Emacs means by a
"variable definition": it "announces your intention to use a symbol as a global
variable." That is probably pretty close to what you mean by "declaring". It
does not mention value initialization (which is optional).
What you presumably want to point out here is that this (a vacuous `defvar')
does not define the variable's _value_. (And it does not define the variable's
doc.)
But the Emacs approach of calling _any_ `defvar' (whether or not it defines the
value and doc) a variable _definition_ is consistent.
If you want to identify that defining with "declaring", that would be fine too.
But if you want to replace that use of "defining" with "declaring" then please
be sure to do so everywhere, and make it clear that from now on "defining"
always means declaring _and initializing_. IOW, make clear that a `defvar' that
does not specify a value is no longer considered a vacuous "definition" etc.
To me, it is clear enough the way Emacs has always spoken: Defining means
declaring and optionally value-initializing. That is, a variable definition
need not also give the variable a value.
A variable definition serves three purposes. First, it
informs people who read the code that the symbol is _intended_
to be used a certain way (as a variable). Second, it informs
the Lisp system of this, optionally supplying an initial value
and a documentation string. Third, it provides information to
programming tools such as `etags', allowing them to find where
the variable was defined.
FWIW - There are currently many, *many* occurrences of "declar" in the Elisp
manual, and *none* of them have to do with `defvar' or `defconst'. Over 99% of
them have to do with functions and macros, and a few have to do with
"customization declarations": `defcustom', `defgroup', and `defface'.
next prev parent reply other threads:[~2013-03-23 18:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-23 16:08 Avoiding 'reference to free variable' warnings while splitting elisp source files Joe Riel
2013-03-23 16:19 ` Avoiding 'reference to free variable' warnings while splittingelisp " Drew Adams
2013-03-23 17:30 ` Stefan Monnier
2013-03-23 18:23 ` Drew Adams [this message]
2013-03-23 21:05 ` Avoiding 'reference to free variable' warnings whilesplittingelisp " Stefan Monnier
2013-03-23 22:41 ` Avoiding 'reference to free variable' warningswhilesplittingelisp " Drew Adams
2013-03-24 9:02 ` Andreas Röhler
2013-03-24 14:34 ` Drew Adams
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=34FC3C03F8024543AA455B46C30A3AE7@us.oracle.com \
--to=drew.adams@oracle.com \
--cc=help-gnu-emacs@gnu.org \
--cc=monnier@iro.umontreal.ca \
/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.