changeset 6632:fc235391e58f

[project @ 2007-05-16 18:21:26 by jwe]
author jwe
date Wed, 16 May 2007 18:21:26 +0000
parents 1b8daf8c0397
children 5af6275fbca9
files doc/ChangeLog doc/interpreter/expr.txi
diffstat 2 files changed, 32 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/doc/ChangeLog	Wed May 16 16:11:56 2007 +0000
+++ b/doc/ChangeLog	Wed May 16 18:21:26 2007 +0000
@@ -1,3 +1,7 @@
+2007-05-16  Søren Hauberg  <hauberg@gmail.com>
+
+	* interpreter/expr.txi: Imrove docs.
+
 2007-05-14  John W. Eaton  <jwe@octave.org>
 
 	* interpreter/basics.txi, interpreter/data.txi,
--- a/doc/interpreter/expr.txi	Wed May 16 16:11:56 2007 +0000
+++ b/doc/interpreter/expr.txi	Wed May 16 18:21:26 2007 +0000
@@ -670,22 +670,31 @@
 @item @var{boolean1} && @var{boolean2}
 @opindex &&
 The expression @var{boolean1} is evaluated and converted to a scalar
-using the equivalent of the operation @code{all (all (@var{boolean1}))}.
+using the equivalent of the operation @code{all (@var{boolean1}(:))}.
 If it is false, the result of the overall expression is 0.  If it is
 true, the expression @var{boolean2} is evaluated and converted to a
-scalar using the equivalent of the operation @code{all (all
-(@var{boolean1}))}.  If it is true, the result of the overall expression
+scalar using the equivalent of the operation @code{all
+(@var{boolean1}(:))}.  If it is true, the result of the overall expression
 is 1.  Otherwise, the result of the overall expression is 0.
 
+@strong{Warning:} there is one exception to the rule of evaluating
+@code{all (@var{boolean1}(:))}, which is when @code{boolean1} is the
+empty matrix. The truth value of an empty matrix is always @code{false}
+so @code{[] && true} evaluates to @code{false} even though
+@code{all ([])} is @code{true}.
+
 @item @var{boolean1} || @var{boolean2}
 @opindex ||
 The expression @var{boolean1} is evaluated and converted to a scalar
-using the equivalent of the operation @code{all (all (@var{boolean1}))}.
+using the equivalent of the operation @code{all (@var{boolean1}(:))}.
 If it is true, the result of the overall expression is 1.  If it is
 false, the expression @var{boolean2} is evaluated and converted to a
-scalar using the equivalent of the operation @code{all (all
-(@var{boolean1}))}.  If it is true, the result of the overall expression
+scalar using the equivalent of the operation @code{all
+(@var{boolean1}(:))}.  If it is true, the result of the overall expression
 is 1.  Otherwise, the result of the overall expression is 0.
+
+@strong{Warning:} the truth value of an empty matrix is always @code{false},
+see the previous list item for details.
 @end table
 
 The fact that both operands may not be evaluated before determining the
@@ -725,6 +734,7 @@
 @end group
 @end example
 
+@noindent
 Writing
 
 @example
@@ -757,6 +767,7 @@
 z = 1
 @end example
 
+@noindent
 After this expression is executed, the variable @code{z} has the value 1.
 Whatever old value @code{z} had before the assignment is forgotten.
 The @samp{=} sign is called an @dfn{assignment operator}.
@@ -879,14 +890,6 @@
 expression need not match.  For example, the expression
 
 @example
-[a, b, c, d] = [u, s, v] = svd (a)
-@end example
-
-@noindent
-is equivalent to the expression above, except that the value of the
-variable @samp{d} is left unchanged, and the expression
-
-@example
 [a, b] = [u, s, v] = svd (a)
 @end example
 
@@ -901,6 +904,17 @@
 @end group
 @end example
 
+@noindent
+The number of values on the left side of the expression can, however,
+not exceed the number of values on the right side. For example, the
+following will produce an error.
+
+@example
+[a, b, c, d] = [u, s, v] = svd (a)
+     @print{} error: element number 4 undefined in return list
+        error: evaluating assignment expression near line 8, column 15
+@end example
+
 You can use an assignment anywhere an expression is called for.  For
 example, it is valid to write @code{x != (y = 1)} to set @code{y} to 1
 and then test whether @code{x} equals 1.  But this style tends to make
@@ -962,12 +976,6 @@
 value of the expression is the @emph{old} value of @var{x}.
 @end table
 
-It is not currently possible to increment index expressions.  For
-example, you might expect that the expression @code{@var{v}(4)++} would
-increment the fourth element of the vector @var{v}, but instead it
-results in a parse error.  This problem may be fixed in a future
-release of Octave.
-
 @node Operator Precedence
 @section Operator Precedence
 @cindex operator precedence