bugGNU Octave - Bugs: bug #52292, behavior of "break"...

 
 

bug #52292: behavior of "break" changed and is now incompatible to Matlab

Submitted by:  Hartmut <hardy>
Submitted on:  Thu 26 Oct 2017 07:45:17 PM UTC  
 
Category: Octave FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Matlab Compatibility
Status: InvalidAssigned to: None
Originator Name: Open/Closed: Closed
Release: devOperating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Fri 27 Oct 2017 05:58:42 PM UTC, comment #4:

Alright. The behavior of current Matlab (see comment #2) convinces me, that it's good for Octave to keep its current (dev Octave) behavior. So I'll get used to using "return" instead of "break" in this case.

@Marco: Thanks for testing.

Hartmut <hardy>
Fri 27 Oct 2017 04:48:26 PM UTC, comment #3:

Looks like Octave is now compatible with current versions of Matlab, so we have increased compatibility with this change. Closing as invalid.

Mike Miller <mtmiller>
Project Administrator
Fri 27 Oct 2017 08:28:43 AM UTC, comment #2:

@ Hartmut: if I run your code in R2017b prompt, I get

If I put your code in a script and run it, I get

Marco Caliari <caliari>
Project Member
Thu 26 Oct 2017 08:24:55 PM UTC, comment #1:

Refer to bug #39168 for the bug report that inspired this change. In that report the user expected that a "break" inside a script that was called from a loop in a different script would break out of the loop.

IMHO you should be using "return" if you want a script to exit early.

Mike Miller <mtmiller>
Project Administrator
Thu 26 Oct 2017 07:45:17 PM UTC, original submission:

The following example code can be run as a script file (let's say example.m) in Octave 4.2.1 and in Matlab R2014b without any problem. But in current dev Octave (e.g. with 209e4f34d243) it throws an error.

The error message in current dev Octave is:

I understand that the content of this error message is correct. I also know that the Matlab help does not encourage this usage of the break command, they say:

Netherless I would like to have this reverted to the previous behavior (i.e. no error message) because:

  • Matlab throws NO error in this case (tested for R2014b, or have they changed this in newer versions?)
  • I am used to using "break" in this way, to conveniently stop a script somewhere in the middle. (I think I've seen others comment on this changed behavior as well.) And I might even like Octave to still support my old habit as an "Octave only" feature, even if Matlab did not support this any more.

What do people think about this? What is a current Matlab version doing in this case? Or should I change my old habit and use "return" from now on?

Hartmut <hardy>

 

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

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by caliari (Posted a comment)
  • -unavailable- added by mtmiller (Posted a comment)
  • -unavailable- added by hardy (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 27 Oct 2017 04:48:26 PM UTCmtmillerStatusNone=>Invalid
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1