octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

return, continue, break -> ans = 1


From: John W. Eaton
Subject: return, continue, break -> ans = 1
Date: Tue, 3 Dec 2002 11:36:52 -0600

On 29-Nov-2002, Miroslaw Kwasniak <address@hidden> wrote:

| To: address@hidden
| Cc: mirek
| Subject: return, continue, break -> ans = 1
| 
| Bug report for Octave 2.1.40 configured for i386-pc-linux-gnu
| 
| Description:
| -----------
| 
| Hi,
| 
|   Control statements: return, continue, break 
| 
|   If they are last statements in a line (not followed by semicolon)
|   octave displays: ans = 1

This is happening because of some changes I made in response to 
http://www.octave.org/mailing-lists/bug-octave/2002/154.  The idea was
to make Octave's break, continue, and return statements behave more
like they do in Perl.  For example, make

  some_expression || break;

work as it would in Perl.  To implement this within the current
parser/interpreter, break must be an expression that returns a value.
But as people have pointed out, that causes a few other surprises for
existing Octave code.

My changes were simple.  They just made break, continue, and return do
what did before, but also behave as functions that returned 1 so they
would be valid in logical contexts.  But a simple change is not good
enough, and I don't see a way to allow the Perl-like behavior and also
be backward compatible without making some major changes to the way
Octave's parser and interpreter work.  I don't think it is worth the
effort and I've undone the changes I made earlier.  The CVS archive
should be updated within a few minutes.

jwe



reply via email to

[Prev in Thread] Current Thread [Next in Thread]