Index: doc/ref/api-control.texi =================================================================== RCS file: /cvsroot/guile/guile/guile-core/doc/ref/api-control.texi,v retrieving revision 1.5 diff -d -u -r1.5 api-control.texi --- doc/ref/api-control.texi 23 Jun 2005 00:10:53 -0000 1.5 +++ doc/ref/api-control.texi 2 Aug 2005 03:12:38 -0000 @@ -108,6 +108,26 @@ the value of @var{test}. The result of this procedure application is then the result of the @code{cond}-expression. address@hidden SRFI-61 address@hidden general cond clause address@hidden multiple values and cond +One additional @code{cond}-clause is available as an extension to +standard Scheme: + address@hidden +(@var{test} @var{guard} => @var{expression}) address@hidden lisp + +where @var{guard} and @var{expression} must evaluate to procedures. +For this clause type, @var{test} may return multiple values, and address@hidden ignores its boolean state; instead, @code{cond} evaluates address@hidden and applies the resulting procedure to the value(s) of address@hidden, as if @var{guard} were the @var{consumer} argument of address@hidden Iff the result of that procedure call is a +true value, it evaluates @var{expression} and applies the resulting +procedure to the value(s) of @var{test}, in the same manner as the address@hidden was called. + The @var{test} of the last @var{clause} may be the symbol @code{else}. Then, if none of the preceding @var{test}s is true, the @var{expression}s following the @code{else} are evaluated to produce the Index: doc/ref/srfi-modules.texi =================================================================== RCS file: /cvsroot/guile/guile/guile-core/doc/ref/srfi-modules.texi,v retrieving revision 1.67 diff -d -u -r1.67 srfi-modules.texi --- doc/ref/srfi-modules.texi 3 May 2005 22:50:21 -0000 1.67 +++ doc/ref/srfi-modules.texi 2 Aug 2005 03:12:44 -0000 @@ -40,6 +40,7 @@ * SRFI-39:: Parameter objects * SRFI-55:: Requiring Features. * SRFI-60:: Integers as bits. +* SRFI-61:: A more general `cond' clause @end menu @@ -2683,6 +2684,16 @@ (list->integer '(#t #f #t #f)) @result{} 10 @end example @end defun + + address@hidden SRFI-61 address@hidden SRFI-61 - A more general @code{cond} clause + +This SRFI extends RnRS @code{cond} to support test expressions that +return multiple values, as well as arbitrary definitions of test +success. SRFI 61 is implemented in the Guile core; there's no module +needed to get SRFI-61 itself. Extended @code{cond} is documented in address@hidden cond case,, Simple Conditional Evaluation}. @c srfi-modules.texi ends here Index: ice-9/boot-9.scm =================================================================== RCS file: /cvsroot/guile/guile/guile-core/ice-9/boot-9.scm,v retrieving revision 1.351 diff -d -u -r1.351 boot-9.scm --- ice-9/boot-9.scm 31 Jul 2005 23:36:50 -0000 1.351 +++ ice-9/boot-9.scm 2 Aug 2005 03:12:44 -0000 @@ -3223,7 +3223,7 @@ ;;; ;;; Currently, the following feature identifiers are supported: ;;; -;;; guile r5rs srfi-0 srfi-4 srfi-6 srfi-13 srfi-14 +;;; guile r5rs srfi-0 srfi-4 srfi-6 srfi-13 srfi-14 srfi-55 srfi-61 ;;; ;;; Remember to update the features list when adding more SRFIs. ;;; @@ -3238,6 +3238,7 @@ srfi-13 ;; string library srfi-14 ;; character sets srfi-55 ;; require-extension + srfi-61 ;; general cond clause )) ;; This table maps module public interfaces to the list of features. Index: libguile/eval.c =================================================================== RCS file: /cvsroot/guile/guile/guile-core/libguile/eval.c,v retrieving revision 1.398 diff -d -u -r1.398 eval.c --- libguile/eval.c 12 Jul 2005 00:28:09 -0000 1.398 +++ libguile/eval.c 2 Aug 2005 03:12:44 -0000 @@ -1095,6 +1095,15 @@ ASSERT_SYNTAX_2 (length == 3, s_extra_expression, clause, expr); SCM_SETCAR (SCM_CDR (clause), SCM_IM_ARROW); } + /* SRFI 61 extended cond */ + else if (length >= 3 + && scm_is_eq (SCM_CADDR (clause), scm_sym_arrow) + && arrow_literal_p) + { + ASSERT_SYNTAX_2 (length > 3, s_missing_recipient, clause, expr); + ASSERT_SYNTAX_2 (length == 4, s_extra_expression, clause, expr); + SCM_SETCAR (SCM_CDDR (clause), SCM_IM_ARROW); + } } SCM_SETCAR (expr, SCM_IM_COND); @@ -3427,7 +3436,29 @@ else { arg1 = EVALCAR (clause, env); - if (scm_is_true (arg1) && !SCM_NILP (arg1)) + /* SRFI 61 extended cond */ + if (!scm_is_null (SCM_CDR (clause)) + && !scm_is_null (SCM_CDDR (clause)) + && scm_is_eq (SCM_CADDR (clause), SCM_IM_ARROW)) + { + SCM xx, guard_result; + if (SCM_VALUESP (arg1)) + arg1 = scm_struct_ref (arg1, SCM_INUM0); + else + arg1 = scm_list_1 (arg1); + xx = SCM_CDR (clause); + proc = EVALCAR (xx, env); + guard_result = SCM_APPLY (proc, arg1, SCM_EOL); + if (scm_is_true (guard_result) + && !SCM_NILP (guard_result)) + { + proc = SCM_CDDR (xx); + proc = EVALCAR (proc, env); + PREP_APPLY (proc, arg1); + goto apply_proc; + } + } + else if (scm_is_true (arg1) && !SCM_NILP (arg1)) { x = SCM_CDR (clause); if (scm_is_null (x))