Hacker News new | ask | show | jobs
by xahlee 3934 days ago
which way to use let is just a personal taste.

When i begin in elisp, i ALWAYS stick with this form of using local var:

    (let (x y z)
     (setq ...)
     (setq ...)
     (setq ...)
     ...
    )
This makes it easier to read all local variable names. Especially when readers are beginners, non-professional programers, scientists, writers.

If we always use this simple style of let, what possible problem can it create?

• Does it creates algorithmic problem? • Does it slow down programs? • Does it violate some computer science principles? • Are there science based proof, or statistics, that shows this style does some damage, such as more difficult to maintain?

The only thing i can think of, is a matter of esthetics.

later on, sometimes i use this form

    (let (x (y 3) (z 4)) body)
with the condition that, if i set the variable in the let parameter, it must be constant. The value never changes in the body. And now sometimes i also use the (let* ...) form.

These variations are just sugar syntax. Not really important. It's a bikeshedding problem.

The thing is, in emacs lisp, there's no way to declare constants. And also, it is unnatural to code elisp or even Common Lisp without lots of setq or setf or similar.

In JavaScript, the issue is much worse. JavaScript Name Hoisting and One-Liner Functional Style http://xahlee.info/js/javascript_name_hosting_and_one-liner_...