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

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

Re: let, let*, oh, why [was: Elisp - Function returning a list]


From: Jean Louis
Subject: Re: let, let*, oh, why [was: Elisp - Function returning a list]
Date: Wed, 16 Dec 2020 18:10:29 +0300
User-agent: Mutt/2.0 (3d08634) (2020-11-07)

* Emanuel Berg via Users list for the GNU Emacs text editor 
<help-gnu-emacs@gnu.org> [2020-12-16 17:34]:
> tomas wrote:
> 
> > What "upwards" means depends on whether you are under
> > dynamic scope (traditional) or lexical scope (more modern,
> > recommended almost always).
> 
> Indeed, put this topmost in your Elisp files:
> 
> ;;; -*- lexical-binding: t -*-

That line is somehow out of sight for me so I just use:

(setq lexical-binding t) as first line in the file.

> Then use `let' and `let*'.
> 
> Write code as one intuitively does, based on functions that do
> stuff and/or return stuff.
> 
> When done, byte compile.
> 
> Simple simple simple. Actually it is much easier to do right
> than to do wrong in this case.

I do follow that workflow as you explained, but it took me time to
find out about it. I do not find it all simple as workflows like that
are not described anywhere. Functions are described in the manual and
everything is there but general practical workflows are not there. In
other words instructions are not well integrated.

Environments like Dr. Racket also try to be self-documented. I still
find Emacs better self-documented than other similar environments.

There are no big deals with dynamic variables as well, one can program
for years without real problem. Then if programmer knows the problem
one can continue programming for decades without entering into
problem. 

> But the byte-compiler will:
> 
>   In test-var:
>   geh.el:210:11: Warning: assignment to free variable ‘some-vari’

Good to have such messages.




reply via email to

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