0

How do you catch the lisp programmer's error:

"I typed let, but I really meant let* and wasted five to ten seconds for the nth time today!"

I make this mistake all the time. Usually in a hurry or not anticipating the dependence of symbols I'm declaring I'll write:

(let ((foo-bar 42)
      (baz-bat (* foo-bar 2))
  (message "I bet you forgot something!"))

Resulting in the irritation in realizing that I miskeyed let* yet again.

Lisp error: (void-variable foo-bar)
  • 1
    github.com/Fuco1/letcheck – wasamasa Dec 14 '16 at 8:12
  • 1
    That "irritating error" is exactly what helps you understand your mistake, no? Just what is your question? Is it how to prevent your making such a mistake? – Drew Dec 14 '16 at 15:12
  • @Drew I was imprecise. My point is not a complaint of the error; the error itself is accurate and perfectly fine. The irritation is my frequent and fundamentally basic user error of misusing let in this particular fashion. I am interested in anything that serves to alert me to the fact or correct the issue before I eval-defun / test the code. Whether the solution is flycheck-style warnings, an autocorrect behavior, a personal policy of exclusively using let*, or something else-- I'm open to input. @wasamasa hit the nail on the head. – ebpa Dec 14 '16 at 15:59
1

I'm aware of letcheck for this, but would prefer to have that kind of linting integrated into one of the tools Flycheck is using, ideally the byte-compiler itself. While one may argue that an unbound variable in a let that suspiciously looks like one of the previous bindings could still be resolved from outer scope, I severely doubt this will ever practically matter. Have you considered handing in a bug for this?

Personally, I just have it ingrained to return to the head of the let expression if I reuse a previous binding and correct it to let*.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.