octave-maintainers
[Top][All Lists]
Advanced

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

Re: return, continue, break -> ans = 1


From: Etienne Grossmann
Subject: Re: return, continue, break -> ans = 1
Date: Tue, 3 Dec 2002 17:55:02 +0000
User-agent: Mutt/1.3.28i

  Hello,

On Tue, Dec 03, 2002 at 11:36:52AM -0600, John W. Eaton wrote:
# 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.

  I only sent the report because I was unaware of the change and
thought it may be the result of some underlying problem. I only
noticed that when some of my functions started printing '1' (the value
of break) wherever I use it w/out a ';' after it. Otherwise, the
perlier, the better. Biased, me?

  Cheers,

  Etienne

  

-- 
Etienne Grossmann ------ http://www.isr.ist.utl.pt/~etienne



reply via email to

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