[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#18059: 24.3.92; defvar and special variables
From: |
Michael Heerdegen |
Subject: |
bug#18059: 24.3.92; defvar and special variables |
Date: |
Sun, 11 Feb 2018 00:59:10 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
Hello Noam,
thanks for working on this.
> +Note that specifying a value, even @code{nil}, marks the variable as
> +special permanently. Whereas if @var{value} is omitted then the
> +variable is only marked special locally (i.e. within the current file
> +or let-block). This can be useful for suppressing byte compilation
> +warnings, see @ref{Compiler Errors}.
After reading this and thinking about it, I'm confused now what the
extent of `defvar' without a specified value is.
In the case of a file, does it mean that the variable is considered
special for the rest of the file, or for the whole file?
And for locally special variables, when you eval
#+begin_src emacs-lisp
;; -*- lexical-binding: t -*-
(defvar testfun nil)
(let ((x 1) f g)
(defvar x)
(setq testfun (lambda () x)))
(funcall testfun)
#+end_src
you get 1, but OTOH
#+begin_src emacs-lisp
;; -*- lexical-binding: t -*-
(defvar testfun nil)
(progn
(defvar x)
(let ((x 1) f g)
(setq testfun (lambda () x))))
(funcall testfun)
#+end_src
gives you an error. I don't really see the connection to a `let' block:
in the first example, the defvar is in a let block, but the variable is
not treated as special in the block. In the second example, it's
outside, but the variable is treated as special (though the extent is
surely not limited to any `let' block).
Michael.
- bug#18059: 24.3.92; defvar and special variables, Noam Postavsky, 2018/02/10
- bug#18059: 24.3.92; defvar and special variables,
Michael Heerdegen <=
- bug#18059: 24.3.92; defvar and special variables, Drew Adams, 2018/02/10
- bug#18059: 24.3.92; defvar and special variables, Noam Postavsky, 2018/02/10
- bug#18059: 24.3.92; defvar and special variables, Stefan Monnier, 2018/02/11
- bug#18059: 24.3.92; defvar and special variables, Noam Postavsky, 2018/02/11
- bug#18059: 24.3.92; defvar and special variables, Michael Heerdegen, 2018/02/11
- bug#18059: 24.3.92; defvar and special variables, Noam Postavsky, 2018/02/11
- bug#18059: 24.3.92; defvar and special variables, Noam Postavsky, 2018/02/13