kiwanami / emacs-deferred

Simple asynchronous functions for emacs lisp
GNU General Public License v3.0
311 stars 43 forks source link

[Suggestion] more ergonomic anamorphic features #56

Open yyoncho opened 4 years ago

yyoncho commented 4 years ago

What do you think about defining a set of anamorphic versions of the functions, like this:

(defmacro deferred::nextc (d &rest body) ;; the prefix could be different.
  `(deferred:nextc ,d (lambda (result)
                        ,@body)))

Here it is how the readme example will look like(using dash's ->).

(-> (deferred::next (message "deferred start"))
    (deferred::nextc 
      (message "chain 1")
      1)
    (deferred::nextc (message "chain 2 : %s" result))
    (deferred::nextc (read-minibuffer "Input a number: "))
    (deferred::nextc (message "Got the number : %i" result))
    (deferred::error (message "Wrong input : %s" error)))
yyoncho commented 4 years ago

any thoughts?