[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Break as valid logical expression
From: |
Pascal A. Dupuis |
Subject: |
Re: Break as valid logical expression |
Date: |
Thu, 14 Nov 2002 02:10:33 -0600 |
On Wed, 13 Nov 2002, John W. Eaton wrote:
> | quite frankly, I don't understand what would mean a "x=break" statement.
>
> Neither do I, which is why I was asking whether these expressions
> (break, continue, return) should be limited to only && and ||
> expressions).
The purpose is to emulate sh and Perl behaviour:
1) evaluate the left part of the logical expression
2) if the result permit to know the final result, then done
3) otherwise, evaluate the right part.
So:
test || break: break only occur if test if false. If it's true, then the
final result is true
test && break: break only occur if test is true. If it's false, then the
final result is false
> I don't know how to limit that given the current implementation of
> Octave's interpreter. As things are now, break, continue, and return
> simply set a global flag which is inspected by the interpreter when
> the next expression is evaluated. In order to be valid in any
> expression context (even if limited to && and || expressions), they
> must return some value.
>
I would suggest having them 'return' some value, but which is
illegal to assign to any variable, so
test || break;
is OK, while
x=(test || break) is not
Regards
Pascal Dupuis
--
Dr. ir. Pascal Dupuis
K. U. Leuven, ESAT/ELECTA (formerly ELEN): http://www.esat.kuleuven.ac.be/
Kasteelpark Arenberg, 10; B-3001 Leuven-Heverlee, Belgium
Tel. +32-16-32 10 12 -- Fax +32-16-32 19 85