* The two-argument form of defvar
@ 2015-03-19 11:39 Philipp Stephani
2015-03-19 15:03 ` Nicolas Richard
0 siblings, 1 reply; 8+ messages in thread
From: Philipp Stephani @ 2015-03-19 11:39 UTC (permalink / raw)
To: help-gnu-emacs@gnu.org
Hi,
when looking at the source code of defvar it becomes clear that the
two-argument form
(defvar foo)
is a no-op. It is often used as a signal to the byte compiler that a
certain variable will be available, similar to declare-function. Would it
be possible to clarify the docstring accordingly? Currently it has no
indication that the two-argument form doesn't do anything.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: The two-argument form of defvar
2015-03-19 11:39 The two-argument form of defvar Philipp Stephani
@ 2015-03-19 15:03 ` Nicolas Richard
2015-03-19 15:52 ` Tassilo Horn
0 siblings, 1 reply; 8+ messages in thread
From: Nicolas Richard @ 2015-03-19 15:03 UTC (permalink / raw)
To: Philipp Stephani; +Cc: help-gnu-emacs@gnu.org
Philipp Stephani <p.stephani2@gmail.com> writes:
> Hi,
>
> when looking at the source code of defvar it becomes clear that the
> two-argument form
>
> (defvar foo)
>
> is a no-op.
Not always a no-op. The source code has this comment :
/* A simple (defvar foo) with lexical scoping does "nothing" except
declare that var to be dynamically scoped *locally* (i.e. within
the current file or let-block). */
To reflect the above comment, the docstring has :
| The `defvar' form also declares the variable as "special",
| so that it is always dynamically bound even if `lexical-binding' is t.
--
Nicolas Richard
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: The two-argument form of defvar
2015-03-19 15:03 ` Nicolas Richard
@ 2015-03-19 15:52 ` Tassilo Horn
2015-04-18 9:25 ` Philipp Stephani
0 siblings, 1 reply; 8+ messages in thread
From: Tassilo Horn @ 2015-03-19 15:52 UTC (permalink / raw)
To: Nicolas Richard; +Cc: Philipp Stephani, help-gnu-emacs@gnu.org
Nicolas Richard <theonewiththeevillook@yahoo.fr> writes:
>> when looking at the source code of defvar it becomes clear that the
>> two-argument form
>>
>> (defvar foo)
>>
>> is a no-op.
>
> Not always a no-op. The source code has this comment :
> /* A simple (defvar foo) with lexical scoping does "nothing" except
> declare that var to be dynamically scoped *locally* (i.e. within
> the current file or let-block). */
>
> To reflect the above comment, the docstring has :
> | The `defvar' form also declares the variable as "special",
> | so that it is always dynamically bound even if `lexical-binding' is t.
But it doesn't *define* anything.
(defvar xxx1 1) ;; C-h v xxx1 works
(defvar xxx2) ;; C-h v xxx2<tab> (No matches)
That behavior is a bit unexpected when the docstring says "Define SYMBOL
as a variable, and return SYMBOL."
Bye,
Tassilo
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: The two-argument form of defvar
2015-03-19 15:52 ` Tassilo Horn
@ 2015-04-18 9:25 ` Philipp Stephani
2015-04-18 13:27 ` Stefan Monnier
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Philipp Stephani @ 2015-04-18 9:25 UTC (permalink / raw)
To: Nicolas Richard, help-gnu-emacs@gnu.org
Maybe there should be a declare-variable function to forward-declare
variables, parallel to declare-function.
Tassilo Horn <tsdh@gnu.org> schrieb am Do., 19. März 2015 um 16:52 Uhr:
> Nicolas Richard <theonewiththeevillook@yahoo.fr> writes:
>
> >> when looking at the source code of defvar it becomes clear that the
> >> two-argument form
> >>
> >> (defvar foo)
> >>
> >> is a no-op.
> >
> > Not always a no-op. The source code has this comment :
> > /* A simple (defvar foo) with lexical scoping does "nothing" except
> > declare that var to be dynamically scoped *locally* (i.e. within
> > the current file or let-block). */
> >
> > To reflect the above comment, the docstring has :
> > | The `defvar' form also declares the variable as "special",
> > | so that it is always dynamically bound even if `lexical-binding' is t.
>
> But it doesn't *define* anything.
>
> (defvar xxx1 1) ;; C-h v xxx1 works
> (defvar xxx2) ;; C-h v xxx2<tab> (No matches)
>
> That behavior is a bit unexpected when the docstring says "Define SYMBOL
> as a variable, and return SYMBOL."
>
> Bye,
> Tassilo
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: The two-argument form of defvar
2015-04-18 9:25 ` Philipp Stephani
@ 2015-04-18 13:27 ` Stefan Monnier
2015-04-18 14:14 ` Drew Adams
[not found] ` <mailman.1013.1429363810.904.help-gnu-emacs@gnu.org>
2 siblings, 0 replies; 8+ messages in thread
From: Stefan Monnier @ 2015-04-18 13:27 UTC (permalink / raw)
To: help-gnu-emacs
>> (defvar xxx2) ;; C-h v xxx2<tab> (No matches)
What kind of info would you expect to get from C-h v xxx2 RET?
All Emacs knows about it at that point is that you intend to use it.
So C-h v wouldn't be able to tell you anything interesting about it.
Stefan
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: The two-argument form of defvar
2015-04-18 9:25 ` Philipp Stephani
2015-04-18 13:27 ` Stefan Monnier
@ 2015-04-18 14:14 ` Drew Adams
2015-04-18 16:50 ` Philipp Stephani
[not found] ` <mailman.1013.1429363810.904.help-gnu-emacs@gnu.org>
2 siblings, 1 reply; 8+ messages in thread
From: Drew Adams @ 2015-04-18 14:14 UTC (permalink / raw)
To: Philipp Stephani, Nicolas Richard, help-gnu-emacs
(FWIW, this thread is about the one-argument form of defvar,
not a two-argument form.)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: The two-argument form of defvar
2015-04-18 14:14 ` Drew Adams
@ 2015-04-18 16:50 ` Philipp Stephani
0 siblings, 0 replies; 8+ messages in thread
From: Philipp Stephani @ 2015-04-18 16:50 UTC (permalink / raw)
To: Drew Adams, Nicolas Richard, help-gnu-emacs
Drew Adams <drew.adams@oracle.com> schrieb am Sa., 18. Apr. 2015 um
16:14 Uhr:
> (FWIW, this thread is about the one-argument form of defvar,
> not a two-argument form.)
>
I intended it to be about the one-argument form, but got the subject wrong.
Probably a habit from other programming languages where the number of
identifiers between ( and ) is the number of arguments.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: The two-argument form of defvar
[not found] ` <mailman.1013.1429363810.904.help-gnu-emacs@gnu.org>
@ 2015-04-19 21:48 ` Emanuel Berg
0 siblings, 0 replies; 8+ messages in thread
From: Emanuel Berg @ 2015-04-19 21:48 UTC (permalink / raw)
To: help-gnu-emacs
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>>> (defvar xxx2) ;; C-h v xxx2<tab> (No matches)
>
> What kind of info would you expect to get from C-h
> v xxx2 RET? All Emacs knows about it at that point
> is that you intend to use it. So C-h v wouldn't be
> able to tell you anything interesting about it.
It could say precisely that - no value, not documented,
only the intention: to use it. It doesn't, and I don't
suggest it should, but it isn't an obviously wrong
thing to do.
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-04-19 21:48 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-19 11:39 The two-argument form of defvar Philipp Stephani
2015-03-19 15:03 ` Nicolas Richard
2015-03-19 15:52 ` Tassilo Horn
2015-04-18 9:25 ` Philipp Stephani
2015-04-18 13:27 ` Stefan Monnier
2015-04-18 14:14 ` Drew Adams
2015-04-18 16:50 ` Philipp Stephani
[not found] ` <mailman.1013.1429363810.904.help-gnu-emacs@gnu.org>
2015-04-19 21:48 ` Emanuel Berg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).