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:39:52 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Joost Kremers wrote:

>> QUESTION: What happens if one does a "setq" on a variable
>> defined in the binding part of the "let"? Can one do that?
>
> Yes, inside the body of the `let`, you can.

You can, but it isn't optimal because if you make a typo you
will be unaware of it and instead a global variable will
silently be created. If it already exist, oh, my you will
modify that instead of the intended let binding variable.

So better to do all computation you reasonably can _before_
the let body, already in the varlist.

Use several steps with `let*' and add supposedly unnecessary
steps for clarity, better access and easier debug.

In the let body, optimally, all computation is already done.
There, you just _do_ whatever it is should happen, using the
values you already have for the purpose.

-- 
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]