Emacs lisp coding style: let forms
The let form
(let ((var1 val1) (var2 val2) …) body)
is getting annoying.
Instead, now just declare var and set them all in the body.
This is simpler, more readible, and more flexible.
Its simpler and easier to read because you have all variable in one place.
Its more flexible because it avoids the
let* form variation that otherwise you need sometimes.
Also avoid the problem where some var is defined in the let while others must be in the body.
Now all in the body. Simple and uniform.
Actually, not sure.
The values form has one strong advantage: it better organize code, both semantic and syntax.
- it is better grouping of code by semantics, because all vars in the let* is about setting up vars. If you use separate setq, even though you may put them all together, but the let* form forces and guarantee the grouping.
- it is better grouping of code by syntax, because for each var there is a parenthesis. (this is better than if use one setq call with mulitple var/val pairs)
Emacs Lisp Misc Essays
- Text Processing vs Structured
- Elisp coding style: let forms
- ELisp Naming Convention
- Some and Every
- What is the Function fn?
- Symbol vs String
- Meaning of Lisp List, Function Type, and Syntax Coloring
- Elisp vs Perl: Validate File Links
- Emacs Lisp: Relation of Curor Position to Begin/End of Matching Pairs in Source Code
- Text Processing: ELisp vs Perl
- Controversy of Common Lisp Package in ELisp
- Lisp List Problem
- Lisp-1 vs Lisp-2
- ELisp Problems: Trim String, Regex Match Data, Lacking Namespace
- Functional Programing: Function Output Should Always Have the Same Structure