bugGNU Octave - Bugs: bug #54058, break does not return from a script

 
 

bug #54058: break does not return from a script

Submitter:  None
Submitted:  Tue 05 Jun 2018 02:08:46 AM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Invalid / Not an Octave Bug Assigned to:  None
Originator Name:  Hale Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 4.4.0
Operating System:  * Microsoft Windows Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 05 Jun 2018 06:08:16 PM UTC, comment #2: 

In older versions of Octave, the break statement did terminate execution of a script.  At one time, I believe that was compatible with Matlab.  Then Matlab changed so that the break statement only works within looping statements and Octave changed to make it compatible once again.

See bug #52292 and bug #39168 for more history.

Handling of Control-C is a separate issue that I believe you have already reported as bug #53953.

John W. Eaton <jwe>
Group administrator
Tue 05 Jun 2018 05:26:14 PM UTC, comment #1: 

The 'break' statement is only useful inside of a for, while, or do loop. If the 'break' statement did return from a script in previous versions of Octave, that was a bug that has been fixed.

Can you give an example of a use case where 'return' does not work as expected?

Mike Miller <mtmiller>
Group Member
Tue 05 Jun 2018 02:08:46 AM UTC, original submission:  

In all previous versions "break" was often used for stopping the script safely without using debug breakpoints. Particularly it was used often for conditional interruption of program.
Thinking about this, it was the only safe and easy to use termination function available.

Starting from 4.4.0, break does not interrupt the script any more.
All the older scripts executed incorrectly now.

It is an awful change in compatibility impermissible for minor version number upgrades!

P.S.
Break is not the same as "return", and older scripts can not always be fixed by substituting "return" there.

Moreover, CTRL+C has limited functionality now. Unlike in the past, it is not passed to child processes from the environment, and does not break the binary modules run from Octave.

So there is virtually no way left for stopping the script safely.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-06-05 jwe StatusNeed Info Invalid / Not an Octave Bug
        Open/ClosedOpen Closed
    2018-06-05 mtmiller StatusNone Need Info
        Summarybreak does not stop the script any more. Compatibility issue! break does not return from a script

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code