[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.3-166-gfb01f
From: |
Andy Wingo |
Subject: |
[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.3-166-gfb01fd8 |
Date: |
Fri, 20 Jan 2012 20:18:42 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".
http://git.savannah.gnu.org/cgit/guile.git/commit/?id=fb01fd87729256ac9740a275ced1dd83dafadfdf
The branch, stable-2.0 has been updated
via fb01fd87729256ac9740a275ced1dd83dafadfdf (commit)
via 9accf3d98ffd1d9d484e5214a9dd9e4054204557 (commit)
from 7d02e256610e37c0ab0e8c55623d6f6c6eacab82 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit fb01fd87729256ac9740a275ced1dd83dafadfdf
Author: Andy Wingo <address@hidden>
Date: Fri Jan 20 21:16:50 2012 +0100
remove duplicate when/unless definitions
* module/rnrs/control.scm:
* module/sxml/ssax.scm:
* test-suite/lalr/common-test.scm: Remove local `when'/`unless'
definitions.
commit 9accf3d98ffd1d9d484e5214a9dd9e4054204557
Author: Andy Wingo <address@hidden>
Date: Fri Jan 20 19:47:02 2012 +0100
add when, unless
* module/ice-9/boot-9.scm (when, unless): New forms.
* doc/ref/api-control.texi (Conditionals): Add docs. Rename this
node from "if cond case".
* doc/ref/r6rs.texi:
* doc/ref/scheme-ideas.texi:
* doc/ref/srfi-modules.texi: Update referrers.
-----------------------------------------------------------------------
Summary of changes:
doc/ref/api-control.texi | 42 ++++++++++++++++++++++++++++++++++----
doc/ref/api-data.texi | 10 ++++----
doc/ref/r6rs.texi | 6 ++--
doc/ref/scheme-ideas.texi | 6 ++--
doc/ref/srfi-modules.texi | 2 +-
module/ice-9/boot-9.scm | 6 +++++
module/rnrs/control.scm | 14 +-----------
module/sxml/ssax.scm | 9 +-------
test-suite/lalr/common-test.scm | 7 ------
9 files changed, 58 insertions(+), 44 deletions(-)
diff --git a/doc/ref/api-control.texi b/doc/ref/api-control.texi
index 5596778..7935d56 100644
--- a/doc/ref/api-control.texi
+++ b/doc/ref/api-control.texi
@@ -12,7 +12,7 @@ flow of Scheme affects C code.
@menu
* begin:: Sequencing and splicing.
-* if cond case:: Simple conditional evaluation.
+* Conditionals:: If, when, unless, case, and cond.
* and or:: Conditional evaluation of a sequence.
* while do:: Iteration mechanisms.
* Prompts:: Composable, delimited continuations.
@@ -103,11 +103,13 @@ good idea. But it is useful to be able to write macros
that expand out
to multiple definitions, as in @code{define-sealant} above, so Scheme
abuses the @code{begin} form for these two tasks.
address@hidden if cond case
address@hidden Conditionals
@subsection Simple Conditional Evaluation
@cindex conditional evaluation
@cindex if
address@hidden when
address@hidden unless
@cindex case
@cindex cond
@@ -121,14 +123,44 @@ values.
All arguments may be arbitrary expressions. First, @var{test} is
evaluated. If it returns a true value, the expression @var{consequent}
is evaluated and @var{alternate} is ignored. If @var{test} evaluates to
address@hidden, @var{alternate} is evaluated instead. The value of the
-evaluated branch (@var{consequent} or @var{alternate}) is returned as
-the value of the @code{if} expression.
address@hidden, @var{alternate} is evaluated instead. The values of the
+evaluated branch (@var{consequent} or @var{alternate}) are returned as
+the values of the @code{if} expression.
When @var{alternate} is omitted and the @var{test} evaluates to
@code{#f}, the value of the expression is not specified.
@end deffn
+When you go to write an @code{if} without an alternate (a @dfn{one-armed
address@hidden), part of what you are expressing is that you don't care
+about the return value (or values) of the expression. As such, you are
+more interested in the @emph{effect} of evaluating the consequent
+expression. (By convention, we use the word @dfn{statement} to refer to
+an expression that is evaluated for effect, not for value).
+
+In such a case, it is considered more clear to express these intentions
+with these special forms, @code{when} and @code{unless}. As an added
+bonus, these forms accept multiple statements to evaluate, which are
+implicitly wrapped in a @code{begin}.
+
address@hidden {Scheme Syntax} when test statement1 statement2 ...
address@hidden {Scheme Syntax} unless test statement1 statement2 ...
+The actual definitions of these forms are in many ways their most clear
+documentation:
+
address@hidden
+(define-syntax-rule (when test stmt stmt* ...)
+ (if test (begin stmt stmt* ...)))
+
+(define-syntax-rule (unless condition stmt stmt* ...)
+ (if (not test) (begin stmt stmt* ...)))
address@hidden example
+
+That is to say, @code{when} evaluates its consequent statements in order
+if @var{test} is true. @code{unless} is the opposite: it evaluates the
+statements if @var{test} is false.
address@hidden deffn
+
@deffn syntax cond clause1 clause2 @dots{}
Each @code{cond}-clause must look like this:
diff --git a/doc/ref/api-data.texi b/doc/ref/api-data.texi
index f2450ce..60a2148 100644
--- a/doc/ref/api-data.texi
+++ b/doc/ref/api-data.texi
@@ -1,6 +1,6 @@
@c -*-texinfo-*-
@c This is part of the GNU Guile Reference Manual.
address@hidden Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2006,
2007, 2008, 2009, 2010, 2011
address@hidden Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2006,
2007, 2008, 2009, 2010, 2011, 2012
@c Free Software Foundation, Inc.
@c See the file guile.texi for copying conditions.
@@ -78,10 +78,10 @@ equality predicates @code{eq?}, @code{eqv?} and
@code{equal?}
#t
@end lisp
-In test condition contexts like @code{if} and @code{cond} (@pxref{if
-cond case}), where a group of subexpressions will be evaluated only if a
address@hidden expression evaluates to ``true'', ``true'' means any
-value at all except @code{#f}.
+In test condition contexts like @code{if} and @code{cond}
+(@pxref{Conditionals}), where a group of subexpressions will be
+evaluated only if a @var{condition} expression evaluates to ``true'',
+``true'' means any value at all except @code{#f}.
@lisp
(if #t "yes" "no")
diff --git a/doc/ref/r6rs.texi b/doc/ref/r6rs.texi
index d054bd3..df14cc0 100644
--- a/doc/ref/r6rs.texi
+++ b/doc/ref/r6rs.texi
@@ -1,6 +1,6 @@
@c -*-texinfo-*-
@c This is part of the GNU Guile Reference Manual.
address@hidden Copyright (C) 2010, 2011
address@hidden Copyright (C) 2010, 2011, 2012
@c Free Software Foundation, Inc.
@c See the file guile.texi for copying conditions.
@@ -316,7 +316,7 @@ grouped below by the existing manual sections to which they
correspond.
@deffn {Scheme Syntax} if test consequence [alternate]
@deffnx {Scheme Syntax} cond clause1 clause2 ...
@deffnx {Scheme Syntax} case key clause1 clause2 ...
address@hidden cond case}, for documentation.
address@hidden, for documentation.
@end deffn
@deffn {Scheme Syntax} and expr ...
@@ -1146,7 +1146,7 @@ exception handler that binds a raised exception to
@var{variable} and
then evaluates the specified @var{clause}s as if they were part of a
@code{cond} expression, with the value of the first matching clause
becoming the value of the @code{guard} expression
-(@pxref{if cond case}). If none of the clause's test expressions
+(@pxref{Conditionals}). If none of the clause's test expressions
evaluates to @code{#t}, the exception is re-raised, with the exception
handler that was current before the evaluation of the @code{guard} form.
diff --git a/doc/ref/scheme-ideas.texi b/doc/ref/scheme-ideas.texi
index 99c07b9..53f7b61 100644
--- a/doc/ref/scheme-ideas.texi
+++ b/doc/ref/scheme-ideas.texi
@@ -1,6 +1,6 @@
@c -*-texinfo-*-
@c This is part of the GNU Guile Reference Manual.
address@hidden Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005
address@hidden Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005,
2012
@c Free Software Foundation, Inc.
@c See the file guile.texi for copying conditions.
@@ -964,11 +964,11 @@ same as a procedure which returns its last argument,
because the
evaluation of a procedure invocation expression does not guarantee to
evaluate the arguments in order.
address@hidden and @code{cond} (@pxref{if cond case}) provide conditional
address@hidden and @code{cond} (@pxref{Conditionals}) provide conditional
evaluation of argument expressions depending on whether one or more
conditions evaluate to ``true'' or ``false''.
address@hidden (@pxref{if cond case}) provides conditional evaluation of
address@hidden (@pxref{Conditionals}) provides conditional evaluation of
argument expressions depending on whether a variable has one of a
specified group of values.
diff --git a/doc/ref/srfi-modules.texi b/doc/ref/srfi-modules.texi
index c2b19fd..2ab9c7a 100644
--- a/doc/ref/srfi-modules.texi
+++ b/doc/ref/srfi-modules.texi
@@ -4193,7 +4193,7 @@ 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}.
address@hidden,, Simple Conditional Evaluation}.
@node SRFI-67
@subsection SRFI-67 - Compare procedures
diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm
index d006d47..86ca875 100644
--- a/module/ice-9/boot-9.scm
+++ b/module/ice-9/boot-9.scm
@@ -412,6 +412,12 @@ If there is no handler at all, Guile prints an error and
then exits."
((_ x) x)
((_ x y ...) (let ((t x)) (if t t (or y ...))))))
+(define-syntax-rule (when test stmt stmt* ...)
+ (if test (begin stmt stmt* ...)))
+
+(define-syntax-rule (unless test stmt stmt* ...)
+ (if (not test) (begin stmt stmt* ...)))
+
;; The "maybe-more" bits are something of a hack, so that we can support
;; SRFI-61. Rewrites into a standalone syntax-case macro would be
;; appreciated.
diff --git a/module/rnrs/control.scm b/module/rnrs/control.scm
index b81c133..25ffa3e 100644
--- a/module/rnrs/control.scm
+++ b/module/rnrs/control.scm
@@ -1,6 +1,6 @@
;;; control.scm --- The R6RS control structures library
-;; Copyright (C) 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2010, 2012 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
@@ -19,14 +19,4 @@
(library (rnrs control (6))
(export when unless do case-lambda)
- (import (only (guile) if not begin define-syntax syntax-rules do
case-lambda))
-
- (define-syntax when
- (syntax-rules ()
- ((when test result1 result2 ...)
- (if test (begin result1 result2 ...)))))
-
- (define-syntax unless
- (syntax-rules ()
- ((unless test result1 result2 ...)
- (if (not test) (begin result1 result2 ...))))))
+ (import (only (guile) when unless do case-lambda)))
diff --git a/module/sxml/ssax.scm b/module/sxml/ssax.scm
index 9709641..a4de0e3 100644
--- a/module/sxml/ssax.scm
+++ b/module/sxml/ssax.scm
@@ -1,6 +1,6 @@
;;;; (sxml ssax) -- the SSAX parser
;;;;
-;;;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+;;;; Copyright (C) 2009, 2010,2012 Free Software Foundation, Inc.
;;;; Modified 2004 by Andy Wingo <wingo at pobox dot com>.
;;;; Written 2001,2002,2003,2004 by Oleg Kiselyov <oleg at pobox dot com>
as SSAX.scm.
;;;;
@@ -209,13 +209,6 @@ string @var{str}, which will then be parsed."
(set! ssax:predefined-parsed-entities
(acons entity str ssax:predefined-parsed-entities)))
-;; if condition is true, execute stmts in turn and return the result of
-;; the last statement otherwise, return #f
-(define-syntax when
- (syntax-rules ()
- ((when condition . stmts)
- (and condition (begin . stmts)))))
-
;; Execute a sequence of forms and return the result of the _first_ one.
;; Like PROG1 in Lisp. Typically used to evaluate one or more forms with
;; side effects and return a value that must be computed before some or
diff --git a/test-suite/lalr/common-test.scm b/test-suite/lalr/common-test.scm
index 8563029..8009148 100644
--- a/test-suite/lalr/common-test.scm
+++ b/test-suite/lalr/common-test.scm
@@ -8,13 +8,6 @@
(define *error* '())
-(define-syntax when
- (syntax-rules ()
- ((_ ?expr ?body ...)
- (if ?expr
- (let () ?body ...)
- #f))))
-
(define-syntax check
(syntax-rules (=>)
((_ ?expr => ?expected-result)
hooks/post-receive
--
GNU Guile
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.3-166-gfb01fd8,
Andy Wingo <=