From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Neil Jerram" Newsgroups: gmane.lisp.guile.user Subject: Re: `lazy-catch' and `dynamic-wind' Date: Sun, 23 Nov 2008 21:34:05 +0000 Message-ID: <49dd78620811231334i1f348223o282423adc009493@mail.gmail.com> References: <87fxliicbt.fsf@gnu.org> 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: ger.gmane.org 1227476075 10161 80.91.229.12 (23 Nov 2008 21:34:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 23 Nov 2008 21:34:35 +0000 (UTC) Cc: guile-user@gnu.org To: "=?ISO-8859-1?Q?Ludovic_Court=E8s?=" Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun Nov 23 22:35:39 2008 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 1L4McE-0001fh-1J for guile-user@m.gmane.org; Sun, 23 Nov 2008 22:35:38 +0100 Original-Received: from localhost ([127.0.0.1]:48317 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L4Mb2-0005lQ-Ac for guile-user@m.gmane.org; Sun, 23 Nov 2008 16:34:24 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L4Mam-0005k5-Bx for guile-user@gnu.org; Sun, 23 Nov 2008 16:34:08 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L4Mal-0005jJ-FO for guile-user@gnu.org; Sun, 23 Nov 2008 16:34:07 -0500 Original-Received: from [199.232.76.173] (port=37352 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L4Mal-0005jC-9J for guile-user@gnu.org; Sun, 23 Nov 2008 16:34:07 -0500 Original-Received: from rv-out-0708.google.com ([209.85.198.240]:9473) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1L4Mal-0004tm-45 for guile-user@gnu.org; Sun, 23 Nov 2008 16:34:07 -0500 Original-Received: by rv-out-0708.google.com with SMTP id k29so1939562rvb.6 for ; Sun, 23 Nov 2008 13:34:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=hwe0XZ2R6GZIrYKp5D3WcmhCY4LQiPx68PgvhwnzEB8=; b=PK5+dyd/gFeN6kHiZgdyRwKD/vCYNeGbuvkmaIQTRmk99ldD6kxHaOGto5JGkDgH66 fz7jNzzruYYRC1BX2jF1e0Hvd7EgNuXXW53MtfCBkL3r1aeMwFunpdW9pUSKRPBtywL7 dIBAAlbCS0Vu5Kai/et/1v01l4syL8ICQOV3I= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=wo8LKjgQJ9p3da2DNiqCzWmVRjVTIaexojbsUnC2Al0GKTH5IGWfJEtc+ftQKNinW7 cBq58Wc28jYRBYEDaYFidPEPA97Ukrd2vDT1NkmK6dJKCSWdxLCbSjaxy6f47dHbn/Ah 6pc7wIAcEZJzg3fUaZumqsEmGcDfI+r0Z4CQU= Original-Received: by 10.141.198.9 with SMTP id a9mr1495908rvq.62.1227476045492; Sun, 23 Nov 2008 13:34:05 -0800 (PST) Original-Received: by 10.140.199.14 with HTTP; Sun, 23 Nov 2008 13:34:05 -0800 (PST) In-Reply-To: <87fxliicbt.fsf@gnu.org> Content-Disposition: inline X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) 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:6970 Archived-At: 2008/11/23 Ludovic Court=E8s : > Hello Guilers! > > I noticed the following subtle difference between fluids and SRFI-39 > parameters when accessed from a `lazy-catch' handler: > > (define fl (make-fluid)) > (fluid-set! fl 'outside) > > (lazy-catch #t > (lambda () > (fluid-set! fl 'inside) > (throw 'foobar)) > (lambda (key . args) > (format #t "fluid =3D ~A~%" (fluid-ref fl)) > (exit 1))) > > =3D> PRINTS: fluid =3D inside This is as expected. Note that there is nothing like dynamic-wind inside fluid-set! Did you perhaps mean with-fluids instead? If you used with-fluids, I would expect the same behaviour as you've described for parameterize. > ... compared to: > > (use-modules (srfi srfi-39)) > > (define fl (make-parameter 'outside)) > > (lazy-catch #t > (lambda () > (parameterize ((fl 'inside)) > (throw 'foobar))) > (lambda (key . args) > (format #t "fluid =3D ~A~%" (fl)) > (exit 1))) > > =3D> PRINTS: fluid =3D outside > > This comes from the fact that `parameterize' sets up a `dynamic-wind' > whose unwinder is called *before* the `lazy-catch' handler. I find it a > bit counter-intuitive since the `lazy-catch' is documented as follows: > > This behaves exactly like `catch', except that it does not unwind > the stack before invoking HANDLER. That text is misleading and should be improved. See the manual section [1] for the whole story, which explains that it is actually only the call stack that is not unwound. [1] http://www.gnu.org/software/guile/manual/html_node/Lazy-Catch.html#Lazy= -Catch This is why I invented with-throw-handler and the optional pre-unwind-handler parameter of `catch'. Perhaps you need to use one of those instead. Regards, Neil