unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Tassilo Horn <tsdh@gnu.org>
To: Nicolas Richard <theonewiththeevillook@yahoo.fr>
Cc: Philipp Stephani <p.stephani2@gmail.com>,
	"help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: Re: The two-argument form of defvar
Date: Thu, 19 Mar 2015 16:52:43 +0100	[thread overview]
Message-ID: <87mw396l2s.fsf@gnu.org> (raw)
In-Reply-To: <87vbhxf2s6.fsf@yahoo.fr> (Nicolas Richard's message of "Thu, 19 Mar 2015 16:03:05 +0100")

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



  reply	other threads:[~2015-03-19 15:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87mw396l2s.fsf@gnu.org \
    --to=tsdh@gnu.org \
    --cc=help-gnu-emacs@gnu.org \
    --cc=p.stephani2@gmail.com \
    --cc=theonewiththeevillook@yahoo.fr \
    /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.
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).