emacs-async icon indicating copy to clipboard operation
emacs-async copied to clipboard

`async-let` does not expand to `let*` (and maybe it needs to)

Open FelipeLema opened this issue 3 years ago • 0 comments

Hey, there

I don't know if I'm misunderstanding what the intention of async-let is. If I understand correctly, it's missing an implicit feature from let* in that every binding inherits the bindings before it.

The following example summarizes my current problem:

(async-let ((default-directory "/")
            (pwd (shell-command-to-string "pwd")))
  (message "%s" pwd)) ;; prints my current directory, instead of "/"

From what I understand from the implementation, each binding is expanded to

`(async-start ,ith-binding-form
              (lambda (,ith-bindng-name)
                ,rest-of-bindings
                ))

Whereas I would expand it into something among these lines

`(async-start ,ith-binding-form
              (lambda (ith-binding-value)
                (let (
                      ,resolved-previous-bindings
                      (,ith-binding-name ith-binding-value))
                  ,rest-of-bindings-or-forms)))

I believe this would resolve the example problem I listed. I haven't supplied an explicit fix for this problem because I don't know if we should fix current async-let or have a separate macro like async-expanding-let* instead.

BTW, this is a great package. I depend on it for my everyday work.

FelipeLema avatar Jan 20 '21 19:01 FelipeLema