From bug-octave-request at bevo dot che dot wisc dot edu Tue Dec 3 11:37:05 2002 Subject: return, continue, break -> ans = 1 From: "John W. Eaton" To: Miroslaw Kwasniak Cc: bug-octave at bevo dot che dot wisc dot edu, Etienne Grossmann , Pascal.Dupuis@esat.kuleuven.ac.be, octave-maintainers mailing list Date: Tue, 3 Dec 2002 11:36:52 -0600 On 29-Nov-2002, Miroslaw Kwasniak wrote: | To: bug-octave at bevo dot che dot wisc dot edu | 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 ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------