Skip to content

Commit

Permalink
Prevent accidental creation of lexical closures.
Browse files Browse the repository at this point in the history
Fixes jwiegley#17. (Try async-test-7)
  • Loading branch information
DarwinAwardWinner committed Oct 17, 2013
1 parent 9c02acd commit 8e05e02
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions async.el
Expand Up @@ -260,8 +260,11 @@ passed to FINISH-FUNC). Call `async-get' on such a future always
returns nil. It can still be useful, however, as an argument to returns nil. It can still be useful, however, as an argument to
`async-ready' or `async-wait'." `async-ready' or `async-wait'."
(require 'find-func) (require 'find-func)
(let ((procvar (make-symbol "proc"))) (let ((procvar (make-symbol "proc"))
`(let* ((sexp ,start-func) ;; Avoid accidental lexical closures by evaluating START-FUNC
;; in an empty lexical environment.
(start-func (eval start-func t)))
`(let* ((sexp #',start-func)
(,procvar (,procvar
(async-start-process (async-start-process
"emacs" (file-truename "emacs" (file-truename
Expand Down

5 comments on commit 8e05e02

@thierryvolpiatto
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about using apply-partially instead of eval?

@DarwinAwardWinner
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That appears to work too.

@DarwinAwardWinner
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it seems to fail some tests when I use apply-partially.

@thierryvolpiatto
Copy link

@thierryvolpiatto thierryvolpiatto commented on 8e05e02 Oct 18, 2013 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DarwinAwardWinner
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I got apply-partially to work correctly. However, I don't really see the advantage over eval.

Please sign in to comment.