On Tue, 2005-08-02 at 10:00 +1000, Kevin Ryde wrote: > I think you should decide now if applications need to use that module > or not. If not then may as well describe the full syntax with the > main `cond' docs.
I went with the "not" route. As I previously wrote, code that breaks on
this would be very odd indeed.
> > +;;; srfi-6.scm --- Basic String Ports
>
> Too much cut and paste :-)
I got lazy :)
Attached is a version with the suggested doc move and no more
srfi-61.scm. Thanks for your recommendations.
Here's a new ChangeLog set, for ice-9/, doc/ref/, and libguile/
respectively:
2005-08-01 Stephen Compall <[EMAIL PROTECTED]>
* boot-9.scm (%cond-expand-features): Add srfi-61.
2005-08-01 Stephen Compall <[EMAIL PROTECTED]>
* api-control.texi (if cond case): Describe SRFI 61 cond.
* srfi-modules.texi (SRFI-61): New section.
(SRFI Support): Add SRFI-61 to menu.
2005-08-01 Stephen Compall <[EMAIL PROTECTED]>
* eval.c (scm_m_cond): Recognize SRFI 61 cond syntax.
(CEVAL): Evaluate SRFI 61 cond clauses.
--
Stephen Compall
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.
[EMAIL PROTECTED] SRFI-61
[EMAIL PROTECTED] general cond clause
[EMAIL PROTECTED] multiple values and cond
+One additional @code{cond}-clause is available as an extension to
+standard Scheme:
+
[EMAIL PROTECTED]
+(@var{test} @var{guard} => @var{expression})
[EMAIL PROTECTED] lisp
+
+where @var{guard} and @var{expression} must evaluate to procedures.
+For this clause type, @var{test} may return multiple values, and
[EMAIL PROTECTED] ignores its boolean state; instead, @code{cond} evaluates
[EMAIL PROTECTED] and applies the resulting procedure to the value(s) of
[EMAIL PROTECTED], as if @var{guard} were the @var{consumer} argument of
[EMAIL PROTECTED] 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
[EMAIL PROTECTED] 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
+
+
[EMAIL PROTECTED] SRFI-61
[EMAIL PROTECTED] 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
[EMAIL PROTECTED] 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))
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Guile-devel mailing list [email protected] http://lists.gnu.org/mailman/listinfo/guile-devel
