From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: David Kastrup Newsgroups: gmane.lisp.guile.user Subject: Re: dynamic-wind Date: Sun, 09 Jul 2017 09:21:18 +0200 Organization: Organization?!? Message-ID: <8737a62hzl.fsf@fencepost.gnu.org> References: <20170702125831.192ddaec@bother.homenet> <87r2xqmx4a.fsf@elektro.pacujo.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1499584925 20339 195.159.176.226 (9 Jul 2017 07:22:05 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 9 Jul 2017 07:22:05 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun Jul 09 09:22:02 2017 Return-path: Envelope-to: guile-user@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 1dU6XZ-00054z-7j for guile-user@m.gmane.org; Sun, 09 Jul 2017 09:22:01 +0200 Original-Received: from localhost ([::1]:35191 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dU6Xe-0000iN-Og for guile-user@m.gmane.org; Sun, 09 Jul 2017 03:22:06 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36649) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dU6XD-0000i7-5Y for guile-user@gnu.org; Sun, 09 Jul 2017 03:21:40 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dU6X9-0001IC-Vw for guile-user@gnu.org; Sun, 09 Jul 2017 03:21:39 -0400 Original-Received: from [195.159.176.226] (port=42795 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dU6X9-0001Hb-PA for guile-user@gnu.org; Sun, 09 Jul 2017 03:21:35 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1dU6Ww-0003DV-HY for guile-user@gnu.org; Sun, 09 Jul 2017 09:21:22 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 60 Original-X-Complaints-To: usenet@blaine.gmane.org X-Face: 2FEFf>]>q>2iw=B6, xrUubRI>pR&Ml9=ao@P@i)L:\urd*t9M~y1^:+Y]'C0~{mAl`oQuAl \!3KEIp?*w`|bL5qr,H)LFO6Q=qx~iH4DN; i"; /yuIsqbLLCh/!U#X[S~(5eZ41to5f%E@'ELIi$t^ Vc\LWP@J5p^rst0+('>Er0=^1{]M9!p?&:\z]|;&=NP3AhB!B_bi^]Pfkw Cancel-Lock: sha1:kBtFBJiTG/6pGO4rxFHQIQzr15w= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:13909 Archived-At: Marko Rauhamaa writes: > Amirouche Boubekki : > >> I consider dynamic-wind an advanced concept not required for usual >> hacking. > > Hm. Python's try/finally has several uses in virtually every program. > > Trouble is, Scheme's continuations make it impossible to know when > something is really final. When there is no reference to it anymore, just like with memory allocation. > In fact, implementing coroutines and cooperative multitasking using > continuations almost guarantee a repeated back-and-forth through > dynamic-wind. > > I strongly suspect Scheme's continuations are more trouble than they > are worth. Depends on your architecture. The basic idea is not to have different memory allocation for heap and return stack. Basically, you put your return "stack" in the heap and never actually reclaim memory when returning but only when garbage collecting. When function calls are hardware-supported but garbage-collection isn't, the trade-offs for that model are not exactly fabulous. Now continuations are not actually pervasively used in Scheme programming like garbage-collection data life times are, and their actual use does not tie greatly into Scheme's call syntax. Yet a lot of core Scheme constructs have constraints on their implementation because the standards prescribe semantics compatible with pervasive use of continuations. So for real-life implementations of Scheme on today's architectures, I find the cost/benefit tradeoff of continuations in relation to the programming language unconvincing. This might change in future architectures: remember that in Fortran's heydays, stuff like stack-local variables and addressing and recursion came with heavy associated costs because the computer architectures were not actually designed to do complex things like stack-relative addressing (anybody remember COMPASS' RJI, return jump instruction, for function calls?). So it's conceivable that garbage collection will become more native (which would also help the data handling speed of any sweeped garbage-collecting language, and there are numerous of them by now) and that procedure handling might be made more compatible with it eventually. It's probably worth mentioning that "ChickenScheme" does this sort of garbage-collection on the stack without actually executing function returns in C. -- David Kastrup