help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: The two-argument form of defvar


From: Tassilo Horn
Subject: Re: The two-argument form of defvar
Date: Thu, 19 Mar 2015 16:52:43 +0100
User-agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (gnu/linux)

Nicolas Richard <address@hidden> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]