all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: SAKURAI Masashi <m.sakurai@kiwanami.net>
To: tzz@lifelogs.com
Cc: emacs-devel@gnu.org
Subject: Re: ELisp futures and continuations/coroutines
Date: Fri, 03 Jun 2011 22:59:48 +0900	[thread overview]
Message-ID: <20110603135948.C290D13C538@vps1.kiwanami.net> (raw)
In-Reply-To: <871uznbki1.fsf@lifelogs.com>


At Tue, 24 May 2011 21:07:50 -0500,
Ted Zlatanov wrote:
>  :
> Also please see the discussion in this thread about url-future.el.  If
> you can consider augmenting that defstruct instead of using the one in
> deferred.el, it would be nice so we're all speaking the same data
> language.  I asked the same of Thien-Thi Nguyen for fsm.el.  But it's
> not a requirement for inclusion in the GNU ELPA and you don't have to do
> it.

I have read all discussion messages in this thread (about more
url-utils and future in elisp) carefully at last. 
Those discussions are so interesting. 
I wrote my comment as follows. Sorry for long comment.


About the "future" type for the just url-fetch function, I think it is
good enough to transfer values asynchronously to the waiting function.
However, I think it is somewhat primitive to construct general
asynchronous programs.

I have met so many difficulties during developing some Emacs
applications[1] which has rich UIs and communication with external
resources, such as handling many callbacks and waiting for them to
finish. For example, getting images by wget -> making thumbnails ->
displaying the images in the buffer, during then, the application
notifies the user of progress of tasks and may display results or
error messages.

OTOH, in JavaScript, there are async supports in many major libs:
jQuery.Deferred, Mochikit.Async, dojo.Deferred and so on. We can
easily write async codes right now. Now, even .NET4[2] provides an
async lib like JSDeferred. So, I'm sure elisp should have async
support too.

While I'm not a researcher for the concurrent programing,
investigating such other async libraries, I found that asynchronous
programing needs at least following two functions:

1) sequential connecting
2) waiting for async tasks done (all of them or the earliest one).

One can define many other aspects of async programing.
Ex. composition of tasks, error handling, canceling, propagating
values, adding tasks after executed, restarting tasks, notifying
progress and so on[3].

Recently, I found an utility program url-queue.el (Fetching web pages
in parallel) was added to lisp/url in trunk. In the single-thread
model like the Emacs, the task queue requires the callback
interface. So, I think some library which supports concurrent
programing model will be needed in near future, like deferred.el 
and concurrent.el.

Furthermore, url-queue.el seems to implement the semaphore which is
one of concurrent patterns. I made the semaphore in concurrent.el
because I needed. I have also seen the similar code in
emacs-w3m[4]. The code of w3m-proc.el manages number of sub-processes
and abstraction of async and sync calling.  So, I think those
concurrent patterns have been needed already.

Though concurrent.el has some patterns those were implemented for my
applications, of course, it doesn't cover all patterns. According to
other languages and some books, STM, Agent, Actor, Reentrant Lock and
Read-Write Lock are argued as concurrent programing.


Last, if my experience of development of deferred.el and concurrent.el
would help the Emacs's advance, I would be happy. I don't mind if
the libraries will be added to GNU ELPA or Emacs, even the maintainers
write a subset code from scratch.

Foot notes:
[1] My deferred.el applications
  * A network multiplayer game which I mentioned the previous post.
  https://github.com/kiwanami/emacs-3d-demo
  (movie) http://www.youtube.com/watch?v=YS5CUj9oUhs
  * In-line image manager with cacoo.com, the on-line diagramming tool
  https://github.com/kiwanami/emacs-cacoo
  (movie) http://www.youtube.com/watch?v=pwZvT5HFQjY
  * PDF file manager
  https://github.com/kiwanami/emacs-anything-books
  (movie) http://www.youtube.com/watch?v=jfEHmgCIc08
  * Inertial scrolling (see the movie of cacoo.el)
  https://github.com/kiwanami/emacs-inertial-scroll

[2] .NET
  * Async Tasks - Simplify Asynchronous Programming with Tasks
  http://msdn.microsoft.com/en-us/magazine/ff959203.aspx
  Moreover, Task and Rx enables to collect async resources by LINQ
  * Reactive Extensions
  http://msdn.microsoft.com/en-us/data/gg577609

[3] Aspects of async libs
  Sorry for only Japanese article I found.
  * (in Japanese)
  http://digitechlog.com/2010/03/12/7-asynchronous-processing-open-source-actionscript-library.html 
  * (machine translation)
  http://translate.google.co.jp/translate?hl=ja&sl=ja&tl=en&u=http://digitechlog.com/2010/03/12/7-asynchronous-processing-open-source-actionscript-library.html
  Following article may be helpful for designing async lib.
  * Virtual Panel: How to Survive Asynchronous Programming in JavaScript (InfoQ)
  http://www.infoq.com/articles/surviving-asynchronous-programming-in-javascript

[4] Emacs-w3m
  * web site: http://emacs-w3m.namazu.org/index-en.html
  * w3m-proc.el: http://cvs.namazu.org/emacs-w3m/w3m-proc.el?view=markup

--
SAKURAI, Masashi (family, given)



  parent reply	other threads:[~2011-06-03 13:59 UTC|newest]

Thread overview: 93+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-14 10:32 more url-utils? joakim
2011-05-14 11:21 ` Lars Magne Ingebrigtsen
2011-05-14 11:42   ` joakim
2011-05-15  1:59     ` Lars Magne Ingebrigtsen
2011-05-14 20:42   ` Dimitri Fontaine
2011-05-15 14:26   ` Jason Rumney
2011-05-16 18:25     ` Ted Zlatanov
2011-05-16 19:03       ` Stefan Monnier
2011-05-16 19:17         ` Ted Zlatanov
2011-05-16 19:22           ` Lennart Borgman
2011-05-16 19:32             ` Ted Zlatanov
2011-05-16 19:33               ` Lennart Borgman
2011-05-16 19:55                 ` Ted Zlatanov
2011-05-16 19:52               ` Julien Danjou
2011-05-16 20:18                 ` Ted Zlatanov
2011-05-17  3:04                   ` Stefan Monnier
2011-05-17  8:13                   ` Julien Danjou
2011-05-16 19:53           ` Stefan Monnier
2011-05-16 21:07             ` joakim
2011-05-16 21:18               ` Ted Zlatanov
2011-05-16 21:21                 ` Lennart Borgman
2011-05-16 21:58                 ` joakim
2011-05-17 11:40             ` Lars Magne Ingebrigtsen
2011-05-17 13:34               ` Stefan Monnier
2011-05-14 13:21 ` Ted Zlatanov
2011-05-16 13:15   ` Stefan Monnier
2011-05-16 15:19     ` Tom Tromey
2011-05-16 15:45       ` Stefan Monnier
2011-05-16 17:04       ` joakim
2011-05-16 17:17         ` Lennart Borgman
2011-05-16 17:30         ` Stefan Monnier
2011-05-16 18:39         ` Julien Danjou
2011-05-15 13:34 ` Chong Yidong
2011-05-17 22:26   ` Ted Zlatanov
2011-05-18  0:11     ` Stefan Monnier
2011-05-18  2:14       ` Ted Zlatanov
2011-05-18 12:16         ` Stefan Monnier
2011-05-18 13:44           ` Ted Zlatanov
2011-05-18 14:09             ` Stefan Monnier
2011-05-18 14:43               ` Ted Zlatanov
2011-05-18 22:05                 ` Stefan Monnier
2011-05-19  1:57                   ` Ted Zlatanov
2011-05-19  2:28                     ` Stefan Monnier
2011-05-19 10:28                       ` Ted Zlatanov
2011-05-19 11:53                         ` Stefan Monnier
2011-05-19 12:43                           ` Ted Zlatanov
2011-05-19 13:28                             ` Stefan Monnier
2011-05-19 13:35                               ` Ted Zlatanov
2011-05-30 17:31                               ` Lars Magne Ingebrigtsen
2011-05-30 19:09                                 ` Stefan Monnier
2011-05-30 19:38                                   ` Lars Magne Ingebrigtsen
2011-05-30 22:17                                     ` Stefan Monnier
2011-05-30 23:11                                       ` Lars Magne Ingebrigtsen
2011-05-31  1:26                                         ` Stefan Monnier
2011-05-31 10:15                                           ` Lars Magne Ingebrigtsen
2011-05-31 12:45                                             ` Stefan Monnier
2011-05-31 18:38                                               ` Lars Magne Ingebrigtsen
2011-05-19 14:11                             ` joakim
2011-05-19 14:40                               ` Stefan Monnier
2011-05-19 13:46                   ` ELisp futures and continuations/coroutines (was: more url-utils?) Ted Zlatanov
2011-05-19 14:15                     ` ELisp futures and continuations/coroutines Stefan Monnier
2011-05-19 14:16                     ` joakim
2011-05-19 15:24                       ` Ted Zlatanov
2011-05-19 15:09                     ` Thien-Thi Nguyen
2011-05-19 15:31                       ` Ted Zlatanov
2011-05-19 16:40                         ` Thien-Thi Nguyen
2011-05-19 23:48                           ` Ted Zlatanov
2011-05-20  1:23                             ` Thien-Thi Nguyen
2011-05-20  4:18                               ` Mohsen BANAN
2011-05-20 15:30                                 ` Ted Zlatanov
2011-05-20 15:29                               ` Ted Zlatanov
2011-05-22 13:17                                 ` Thien-Thi Nguyen
2011-05-23 14:24                                   ` Ted Zlatanov
2011-05-23 14:59                                     ` Stefan Monnier
2011-05-23 15:10                                       ` Ted Zlatanov
2011-05-23 15:42                                         ` SAKURAI Masashi
2011-05-25  2:07                                           ` Ted Zlatanov
2011-05-26  0:23                                             ` SAKURAI Masashi
2011-06-03 13:59                                             ` SAKURAI Masashi [this message]
2011-06-03 16:06                                               ` Ted Zlatanov
2011-06-04  6:21                                                 ` SAKURAI Masashi
2011-06-29  5:31                                                 ` SAKURAI Masashi
2011-06-29 12:01                                                   ` Ted Zlatanov
2011-06-29 17:33                                                     ` SAKURAI Masashi
2011-06-29 16:09                                                   ` Chong Yidong
2011-05-23 15:45                                         ` Stefan Monnier
2011-05-25  2:02                                           ` Ted Zlatanov
2011-05-31 10:53                                             ` Ted Zlatanov
2011-05-31 16:55                                               ` Ted Zlatanov
2011-05-19 17:03                     ` ELisp futures and continuations/coroutines (was: more url-utils?) SAKURAI Masashi
2011-05-19 22:51                       ` ELisp futures and continuations/coroutines Ted Zlatanov
2011-05-20 15:49                         ` SAKURAI Masashi
2011-05-25  2:17                           ` Ted Zlatanov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110603135948.C290D13C538@vps1.kiwanami.net \
    --to=m.sakurai@kiwanami.net \
    --cc=emacs-devel@gnu.org \
    --cc=tzz@lifelogs.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.