From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: "John Wiegley" Newsgroups: gmane.emacs.devel Subject: Re: Delimited continuations Date: Sun, 10 Dec 2017 11:59:16 -0800 Message-ID: References: <87r2s2cyoj.fsf@web.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1512935975 3892 195.159.176.226 (10 Dec 2017 19:59:35 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 10 Dec 2017 19:59:35 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (darwin) Cc: emacs-devel@gnu.org To: Michael Heerdegen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Dec 10 20:59:28 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eO7l1-0000cM-C1 for ged-emacs-devel@m.gmane.org; Sun, 10 Dec 2017 20:59:28 +0100 Original-Received: from localhost ([::1]:49560 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eO7l6-0002ep-Q9 for ged-emacs-devel@m.gmane.org; Sun, 10 Dec 2017 14:59:32 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40317) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eO7kz-0002ej-Fg for emacs-devel@gnu.org; Sun, 10 Dec 2017 14:59:26 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eO7kv-0007h5-KG for emacs-devel@gnu.org; Sun, 10 Dec 2017 14:59:25 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:52591) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eO7kv-0007gy-Gv; Sun, 10 Dec 2017 14:59:21 -0500 Original-Received: from auth2-smtp.messagingengine.com ([66.111.4.228]:51737) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.82) (envelope-from ) id 1eO7kv-0002wn-7i; Sun, 10 Dec 2017 14:59:21 -0500 Original-Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailauth.nyi.internal (Postfix) with ESMTP id 4AACA202D4; Sun, 10 Dec 2017 14:59:20 -0500 (EST) Original-Received: from frontend2 ([10.202.2.161]) by compute4.internal (MEProxy); Sun, 10 Dec 2017 14:59:20 -0500 X-ME-Sender: Original-Received: from localhost (76-234-69-149.lightspeed.frokca.sbcglobal.net [76.234.69.149]) by mail.messagingengine.com (Postfix) with ESMTPA id D3CD824E76; Sun, 10 Dec 2017 14:59:19 -0500 (EST) In-Reply-To: <87r2s2cyoj.fsf@web.de> (Michael Heerdegen's message of "Sun, 10 Dec 2017 17:53:00 +0100") Mail-Followup-To: Michael Heerdegen , emacs-devel@gnu.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.devel:220854 Archived-At: >>>>> "MH" == Michael Heerdegen writes: HM> (+ 1 2) is executed twice. I think this isn't necessarily so? Yes, except if you think about it, this "initial evaluation" whose results are thrown away can be used to establish lexical bindings to be captured by the lambda passed to shift; or to influence which shift is used within a complicated reset block. HM> BTW, I wonder what one can potentially do with this stuff. Although it's in Haskell, this is my favorite article on motivating the expressive power of delimited continuations: http://blog.moertel.com/posts/2005-09-13-scope-herding-with-delimited-continuations.html Note that rather than simply using shift/reset lexically -- which *could* be replaced by a lambda form parameterized over the insertion points -- it uses shift/reset as the power behind a helper function. Even his example, however, is a bit less meaningful in a context where side- effects and dynamic binding are freely available. -- John Wiegley GPG fingerprint = 4710 CF98 AF9B 327B B80F http://newartisans.com 60E1 46C4 BD1A 7AC1 4BA2