unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* false-if-exception environment
@ 2003-12-09 20:33 Kevin Ryde
  2004-01-06 21:34 ` Kevin Ryde
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Ryde @ 2003-12-09 20:33 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 381 bytes --]

        * 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.


[-- Attachment #2: boot-9.scm.false.diff --]
[-- Type: text/plain, Size: 389 bytes --]

--- 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.
 ;;;

[-- Attachment #3: exceptions.test.false.diff --]
[-- Type: text/plain, Size: 1392 bytes --]

--- 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)))))

[-- Attachment #4: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: false-if-exception environment
  2003-12-09 20:33 false-if-exception environment Kevin Ryde
@ 2004-01-06 21:34 ` Kevin Ryde
  2004-01-10 23:40   ` Marius Vollmer
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Ryde @ 2004-01-06 21:34 UTC (permalink / raw)


I wrote:
>
>         * boot-9.scm (false-if-exception): Add unquoting to catch and
>         lambda, so as not to depend on expansion environment.

I applied this, but I see it breaks r5rs_pitfall.test.

I think the motivation for the change is sound, maybe some other style
is needed to cooperate with r5rs_pitfall.test.

Looks like trouble with false-if-exception within syntax-rules.


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: false-if-exception environment
  2004-01-06 21:34 ` Kevin Ryde
@ 2004-01-10 23:40   ` Marius Vollmer
  0 siblings, 0 replies; 3+ messages in thread
From: Marius Vollmer @ 2004-01-10 23:40 UTC (permalink / raw)


Kevin Ryde <user42@zip.com.au> writes:

> I wrote:
>>
>>         * boot-9.scm (false-if-exception): Add unquoting to catch and
>>         lambda, so as not to depend on expansion environment.
>
> I applied this, but I see it breaks r5rs_pitfall.test.

Please unapply it, then.  The right thing would be to use syntax-rules
or syntax-case for all macros, but we are not yet ready for that.

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-01-10 23:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-12-09 20:33 false-if-exception environment Kevin Ryde
2004-01-06 21:34 ` Kevin Ryde
2004-01-10 23:40   ` Marius Vollmer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).