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

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

Re: Understanding the "let" construct and the setting of variables


From: Emanuel Berg
Subject: Re: Understanding the "let" construct and the setting of variables
Date: Fri, 18 Dec 2020 21:46:38 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

steve-humphreys wrote:

> This gets me to "defvar". I have read that "setq" does net
> actually make a variable. It is defvar that makes a variable
> available. When reading the "Intro to Emacs Lisp", the focus
> is on using "setq".

`setq' is enough, it does the real job alright, but the
byte-compiler will complain if there isn't a `defvar'
before it.

Also with defvar you can set a default value and add
a docstring. None of that is mandatory and the default value
can even be confusing IMO.

Just think of defvar as a way of telling Emacs and everyone
else, "I intend to use a variable with this name."

This is enough, and always do it (_at least_ do that, of
course by all means set the default and add a docstring if
that fancies you), but always and at least do this:

(defvar some-var)
(setq   some-var some-value)

That's enough. You have what you need and the byte-compiler
doesn't complain.

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




reply via email to

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