From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: SAKURAI Masashi Newsgroups: gmane.emacs.devel Subject: Re: ELisp futures and continuations/coroutines (was: more url-utils?) Date: Fri, 20 May 2011 02:03:54 +0900 Message-ID: <20110519170354.3E15F13C514@vps1.kiwanami.net> References: <87fwogaxzb.fsf@stupidchicken.com> <87mxilezg8.fsf@lifelogs.com> <87boz0eov8.fsf@lifelogs.com> <87mxikrulm.fsf@lifelogs.com> <871uzw5asv.fsf@lifelogs.com> <878vu2ztua.fsf_-_@lifelogs.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII X-Trace: dough.gmane.org 1305824653 30870 80.91.229.12 (19 May 2011 17:04:13 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 19 May 2011 17:04:13 +0000 (UTC) Cc: emacs-devel@gnu.org To: tzz@lifelogs.com Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu May 19 19:04:09 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QN6do-0003Bs-Vx for ged-emacs-devel@m.gmane.org; Thu, 19 May 2011 19:04:05 +0200 Original-Received: from localhost ([::1]:39920 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QN6do-0007kV-Ae for ged-emacs-devel@m.gmane.org; Thu, 19 May 2011 13:04:04 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:54624) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QN6dl-0007kA-Co for emacs-devel@gnu.org; Thu, 19 May 2011 13:04:02 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QN6dk-0004yy-4G for emacs-devel@gnu.org; Thu, 19 May 2011 13:04:01 -0400 Original-Received: from vps1.kiwanami.net ([182.48.41.71]:40100) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QN6dj-0004yI-Sf for emacs-devel@gnu.org; Thu, 19 May 2011 13:04:00 -0400 Original-Received: from liza2.kiwanami.net (localhost [127.0.0.1]) by vps1.kiwanami.net (Postfix) with ESMTP id 3E15F13C514; Fri, 20 May 2011 02:03:54 +0900 (JST) In-Reply-To: <878vu2ztua.fsf_-_@lifelogs.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/23.2 Mule/6.0 (HANACHIRUSATO) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 182.48.41.71 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:139525 Archived-At: Hi, Ted I have just made an asynchronous library, deferred.el and concurrent.el. deferred.el : https://github.com/kiwanami/emacs-deferred/blob/master/README.markdown concurrent.el : https://github.com/kiwanami/emacs-deferred/blob/master/README-concurrent.markdown deferred.el is inspired by JSDeferred that comes from Mochikit.Async(JS) and Twisted(Python). The chain of asynchronous callbacks likes the continuation. Indeed, concurrent.el that is build on deferred.el, has the pseud-thread, the generator and the dataflow variable which may be similar to a "future" type. A sample code of concurrent.el https://github.com/kiwanami/emacs-deferred/blob/master/concurrent-sample.el Here is a demo for the networking and UI thread. (Sorry for machine translation...) http://translate.google.co.jp/translate?js=n&prev=_t&hl=ja&ie=UTF-8&layout=2&eotf=1&sl=ja&tl=en&u=http://d.hatena.ne.jp/kiwanami/20110413/1302709536 I have written some applications built on deferred.el and I found it works well. I think handling of asynchronous callbacks is getting important for the Emacs in the future. Because the Emacs interpreter is built on the single thread model (Node.js also employs the single thread model), the Emacs Lisp should have a way to write complicated asynchronous codes more easily. I would like to include deferred.el in the Emacs package. -- SAKURAI, Masashi (family, given) At Thu, 19 May 2011 08:46:21 -0500, Ted Zlatanov wrote: > > On Wed, 18 May 2011 19:05:57 -0300 Stefan Monnier wrote: > > SM> That's a good idea. Kind of like a future. > > Speaking of futures, can we have a general facility for those? > > 1) a real "future" type > > 2) a way to construct it and check if the value is available > > 3) process sentinel tie-in > > I'm sure much of this facility is either possible or already available > in ELisp, I just don't know the pieces and I think it would be very > convenient to provide a "future" type. WDYT? > > Similarly it would be very nice to provide continuations and coroutines > if those are not already possible. They don't need a top-level type > though, a lexical closure is sufficient I think. Please tell me how I'm > wrong :) > > Ted > >