From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kevin Ryde Newsgroups: gmane.lisp.guile.devel Subject: false-if-exception environment Date: Wed, 10 Dec 2003 06:33:34 +1000 Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: <87zne1enoh.fsf@zip.com.au> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1071003031 20070 80.91.224.253 (9 Dec 2003 20:50:31 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 9 Dec 2003 20:50:31 +0000 (UTC) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Dec 09 21:50:28 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1ATooO-0006QY-00 for ; Tue, 09 Dec 2003 21:50:28 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1ATpZa-0001lY-M5 for guile-devel@m.gmane.org; Tue, 09 Dec 2003 16:39:14 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1ATpZ2-0001kk-M8 for guile-devel@gnu.org; Tue, 09 Dec 2003 16:38:40 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1ATpVv-0000sH-0N for guile-devel@gnu.org; Tue, 09 Dec 2003 16:35:59 -0500 Original-Received: from [61.8.0.36] (helo=snoopy.pacific.net.au) by monty-python.gnu.org with esmtp (Exim 4.24) id 1ATpVs-0000qU-Mm for guile-devel@gnu.org; Tue, 09 Dec 2003 16:35:24 -0500 Original-Received: from mongrel.pacific.net.au (mongrel.pacific.net.au [61.8.0.107]) by snoopy.pacific.net.au (8.12.3/8.12.3/Debian-6.6) with ESMTP id hB9KXuno005640 for ; Wed, 10 Dec 2003 07:33:56 +1100 Original-Received: from localhost (ppp159.dyn16.pacific.net.au [61.8.16.159]) by mongrel.pacific.net.au (8.12.3/8.12.3/Debian-6.6) with ESMTP id hB9KXsxs022192 for ; Wed, 10 Dec 2003 07:33:55 +1100 Original-Received: from gg by localhost with local (Exim 3.35 #1 (Debian)) id 1AToY5-0002JU-00; Wed, 10 Dec 2003 06:33:37 +1000 Original-To: guile-devel@gnu.org Mail-Copies-To: never User-Agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3 (gnu/linux) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Developers list for Guile, the GNU extensibility library List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.devel:3111 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:3111 --=-=-= * boot-9.scm (false-if-exception): Add unquoting to catch and lambda, so as not to depend on expansion environment. * tests/exceptions.test (false-if-exception): Add tests. This aims to permit for instance, (let ((catch 1) (fish 2)) (false-if-exception 123)) I don't claim shadowing "catch" is a good thing, but I'd think it ought to work. --=-=-= Content-Disposition: attachment; filename=boot-9.scm.false.diff --- boot-9.scm.~1.324.~ 2003-11-21 06:28:26.000000000 +1000 +++ boot-9.scm 2003-12-09 07:56:47.000000000 +1000 @@ -3326,8 +3326,8 @@ signals old-handlers)))))) (defmacro false-if-exception (expr) - `(catch #t (lambda () ,expr) - (lambda args #f))) + `(,catch #t (,lambda () ,expr) + (,lambda args #f))) ;;; This hook is run at the very end of an interactive session. ;;; --=-=-= Content-Disposition: attachment; filename=exceptions.test.false.diff --- exceptions.test.~1.8.~ 2003-04-07 08:05:30.000000000 +1000 +++ exceptions.test 2003-12-09 07:53:06.000000000 +1000 @@ -1,5 +1,5 @@ ;;;; exceptions.test --- tests for Guile's exception handling -*- scheme -*- -;;;; Copyright (C) 2001 Free Software Foundation, Inc. +;;;; Copyright (C) 2001, 2003 Free Software Foundation, Inc. ;;;; ;;;; This library is free software; you can redistribute it and/or ;;;; modify it under the terms of the GNU Lesser General Public @@ -16,6 +16,8 @@ ;;;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +(use-modules (test-suite lib)) + (with-test-prefix "throw/catch" (with-test-prefix "wrong type argument" @@ -59,3 +61,24 @@ (catch 'a (lambda () (throw 'a)) (lambda (x y . rest) #f))))) + +(with-test-prefix "false-if-exception" + + (pass-if (false-if-exception #t)) + (pass-if (not (false-if-exception #f))) + (pass-if (not (false-if-exception (error "xxx")))) + + (with-test-prefix "in empty environment" + ;; an environment with no bindings at all + (define empty-environment + (make-module 1)) + + (pass-if "#t" + (eval `(,false-if-exception #t) + empty-environment)) + (pass-if "#f" + (not (eval `(,false-if-exception #f) + empty-environment))) + (pass-if "exception" + (not (eval `(,false-if-exception (,error "xxx")) + empty-environment))))) --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel --=-=-=--