From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Marco Maggi" Newsgroups: gmane.lisp.guile.user Subject: Re: using compensations stacks with Guile Date: Wed, 2 May 2007 21:29:15 +0200 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1178135373 30368 80.91.229.12 (2 May 2007 19:49:33 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 2 May 2007 19:49:33 +0000 (UTC) To: "guile-user" Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed May 02 21:49:32 2007 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HjKpM-0000rs-7B for guile-user@m.gmane.org; Wed, 02 May 2007 21:49:28 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HjKvn-0005uM-BV for guile-user@m.gmane.org; Wed, 02 May 2007 15:56:07 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HjKvj-0005uB-Ui for guile-user@gnu.org; Wed, 02 May 2007 15:56:03 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HjKvj-0005tt-3G for guile-user@gnu.org; Wed, 02 May 2007 15:56:03 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HjKvj-0005tq-0w for guile-user@gnu.org; Wed, 02 May 2007 15:56:03 -0400 Original-Received: from relay-pt3.poste.it ([62.241.4.129]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HjKpG-0008PC-T2 for guile-user@gnu.org; Wed, 02 May 2007 15:49:23 -0400 Original-Received: from poste.it (192.168.144.50) by relay-pt3.poste.it (7.2.063) (authenticated as marco.maggi-ipsu@poste.it) id 4637C6C000012F37 for guile-user@gnu.org; Wed, 2 May 2007 21:29:15 +0200 X-Sensitivity: 3 X-XaM3-API-Version: 4.3 (R1) (B3pl19) X-SenderIP: 81.211.189.41 X-detected-kernel: Solaris 9 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:5940 Archived-At: "Ludovic Courts" wrote: > I haven't read the paper you mention there but that > looks very similar to what `dynamic-wind' does. There are differences between using 'with-compensations' and using 'dynamic-wind' with alloc forms in the in-guard and the free forms in the out-guard: 1. 'dynamic-wind' separates the alloc code from the free code, while 'compensate' allows them to be one near the other; 2. when an error occurs inside the in-guard or inside the out-guard the free functions are not invoked; with: (dynamic-wind (lambda () (display 'alloc-a)(newline) (display 'alloc-b)(newline) (display 'alloc-c)(newline)) (lambda () (format #t "ciao~%")) (lambda () (display 'free-c)(newline) (display 'free-b)(newline) (display 'free-a)(newline))) no error, everything is fine; with: (dynamic-wind (lambda () (display 'alloc-a)(newline) (display 'alloc-b)(newline) (display 'alloc-c)(newline)) (lambda () (format #t "ciao~%") (throw 'misc-error)) (lambda () (display 'free-c)(newline) (display 'free-b)(newline) (display 'free-a)(newline))) 'dynamic-wind' does its job, all right; with: (dynamic-wind (lambda () (display 'alloc-a)(newline) (display 'alloc-b)(newline) (display 'alloc-c)(newline)) (lambda () (format #t "ciao~%")) (lambda () (display 'free-c)(newline) (throw 'misc-error) (display 'free-b)(newline) (display 'free-a)(newline))) 'free-b' and 'free-a' are not displayed: a and b are leaked; with: (dynamic-wind (lambda () (display 'alloc-a)(newline) (display 'alloc-b)(newline) (throw 'misc-error) (display 'alloc-c)(newline)) (lambda () (format #t "ciao~%")) (lambda () (display 'free-c)(newline) (display 'free-b)(newline) (display 'free-a)(newline))) 'free-a' and 'free-b' are not displayed: a and b are leaked; with a compensations stack these cases are handled correctly. -- Marco Maggi "They say jump!, you say how high?" Rage Against the Machine - "Bullet in the Head" _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://lists.gnu.org/mailman/listinfo/guile-user