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

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

bug#18059: 24.3.92; defvar and special variables


From: Noam Postavsky
Subject: bug#18059: 24.3.92; defvar and special variables
Date: Tue, 13 Feb 2018 19:27:43 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux)

Noam Postavsky <npostavs@users.sourceforge.net> writes:

> Stefan Monnier <monnier@IRO.UMontreal.CA> writes:
>
>>> I noticed doing (let () (defvar x)) seems to be the same as (progn
>>> (defvar x)), which may be a bug.
>>
>> Both interpretations would make sense, so given the lack of
>> documentation about the intention, we could consider it as a feature as
>> much as a bug.
>>
>> Have you checked whether the behavior is the same with the
>> byte-compiler?
>
> Yes, it's the same.

It's the same when let-binding a lexical variable, but not when binding
a dynamic one.

    ;; -*- lexical-binding: t -*-

    (defvar foo-dynamic 'foo)

    (let ((foo-dynamic 99))
      (defvar x))

    (let ((x 1))
      (setq testfun (lambda () x)))

    (message "%S" (funcall testfun))

gives

    Symbol’s value as variable is void: x

when running the interpreted version, and

    1

when running the compiled version.





reply via email to

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