From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: John Wiegley Newsgroups: gmane.emacs.devel Subject: Re: async 1.0 Date: Sat, 23 Jun 2012 16:05:08 -0500 Message-ID: References: <87vcij7rvi.fsf@mithlond.arda> <82d34r8ej9.fsf@gmail.com> <877guya6jz.fsf@uwakimon.sk.tsukuba.ac.jp> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1340485519 26105 80.91.229.3 (23 Jun 2012 21:05:19 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 23 Jun 2012 21:05:19 +0000 (UTC) Cc: Emacs developers To: "Stephen J. Turnbull" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jun 23 23:05:18 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SiXW9-0002or-Ot for ged-emacs-devel@m.gmane.org; Sat, 23 Jun 2012 23:05:18 +0200 Original-Received: from localhost ([::1]:56783 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SiXW9-0000i6-M2 for ged-emacs-devel@m.gmane.org; Sat, 23 Jun 2012 17:05:17 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:58821) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SiXW6-0000i1-Va for emacs-devel@gnu.org; Sat, 23 Jun 2012 17:05:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SiXW5-00021q-0e for emacs-devel@gnu.org; Sat, 23 Jun 2012 17:05:14 -0400 Original-Received: from mail-ob0-f169.google.com ([209.85.214.169]:36624) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SiXW4-00020P-Og for emacs-devel@gnu.org; Sat, 23 Jun 2012 17:05:12 -0400 Original-Received: by obhx4 with SMTP id x4so5093289obh.0 for ; Sat, 23 Jun 2012 14:05:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:mail-followup-to:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=rumiF1nBKbgcVFbJtCy2roqfFkvT45lTtjI0tk9Aau8=; b=h1XzmsDZoamiHhyT26bFHi4HHpCpXjRSQlICx71qvx+bZCB7L2xBtxaZpwRwws3q17 yUS/goi9D81hw2T1YJgmxDYJ0YeR6mh/Ytlf/p1zYnX46N4MVHretB6T5STFHz029z2F pzIGr3JnCKVqhdmBkM1xD2GI1A2OuHM9eiu/KH5wZt6kHmnGlh64bVs8I3bajBtkVlLt M6IAfA8yn+McwjK9E2T9/ZA6RQIvX4itz4WzZAxd9DZpNe3QUGmtxGne/JhB+RrPegW/ Zu1Vci1cJtv93xWJgJSGPQYvoDoRERPsVxXWFckws+S9jBACGLNHqlX1I9t/BboQvUY2 F6Kw== Original-Received: by 10.50.212.70 with SMTP id ni6mr4709859igc.30.1340485509749; Sat, 23 Jun 2012 14:05:09 -0700 (PDT) Original-Received: from vulcan.local (c-98-215-105-167.hsd1.il.comcast.net. [98.215.105.167]) by mx.google.com with ESMTPS id gh2sm6639570igb.9.2012.06.23.14.05.08 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 23 Jun 2012 14:05:09 -0700 (PDT) Original-Received: by vulcan.local (Postfix, from userid 501) id 3E6F2F0484B9; Sat, 23 Jun 2012 16:05:08 -0500 (CDT) Mail-Followup-To: "Stephen J. Turnbull" , Emacs developers In-Reply-To: <877guya6jz.fsf@uwakimon.sk.tsukuba.ac.jp> (Stephen J. Turnbull's message of "Sat, 23 Jun 2012 15:25:20 +0900") User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.1 (darwin) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.214.169 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:151117 Archived-At: >>>>> Stephen J Turnbull writes: > XEmacs efs (or maybe it's dired -- not to be confused with any dired in > Emacs IIRC, you need the XEmacs versions) has an implementation of call/cc. > I don't know how close to "true" call/cc it is. For correct info, ask Mike > Sperber . I'll have to check that out. Eshell has a poor man's implementation of call/cc, called `eshell-do-eval'. It throws `eshell-defer' as the equivalent of calling `call/cc', returning an object you can `eval' later to resume execution. The way it works is by taking the form you want to `eval' and transforming it as it evaluates, performing substitutions so that (let ((a (+ 10 20))) ...) becomes (let ((a 30)) ...), etc., on down to where you throw `eshell-defer' (and of course removing the throw). The next time you evaluate, no additional evaluations are done until you reach the point where you deferred. The downsides are: (a) it's slow to walk and eval in Lisp, (b) it doesn't work with byte-compiled forms, and (c) it's limited to a subset of the Emacs Lisp language, since each single special form needs to be treated specially, and I only implemented transforms for the ones that Eshell actually used. Oh, and (a) it doesn't peer past function call boundaries. That said, it could be extended to fully support Emacs Lisp; it would simply require that nothing be byte-compiled. Unless bytecode stream instrumentation was added to the mix... On the other hand, how hard would it be to make Emacs stackless and provide a native call/cc that works not only with byte-compiled code, but with interposing native function calls? For example: (let* ((a (+ 10 20)) (c '(1 2 3))) (d (mapcar #'(lambda (b) (+ b a) (call/cc)) c))) I cannot think of any way to fake continuations here, other than having intimate of every native function, and transforming the `let' into this: (let* ((a 30) (b '(2 3)) (d (cons 1 (mapcar #'(lambda (b) (+ b a)) c)))) The problem gets pretty hairy fairly quickly. John