bugGNU Octave - Bugs: bug #39168, break command at top-level in...

 
 

bug #39168: break command at top-level in script has no effect on loop in calling context

Submitter:  Rouhollah <paryshaan>
Submitted:  Wed 05 Jun 2013 08:42:11 AM UTC
 
Category:  Octave Function Severity:  2 - Minor
Priority:  3 - Low Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       

 

( Jump to the original submission )

Thu 17 Nov 2016 07:18:30 PM UTC, comment #6: 

Ok, calling this fixed.

Mike Miller <mtmiller>
Project Administrator
Thu 17 Nov 2016 07:16:15 PM UTC, comment #5: 

I don't think so.

John W. Eaton <jwe>
Project Administrator
Thu 17 Nov 2016 06:38:24 PM UTC, comment #4: 

So is the example posted here not expected to work in a current release of Matlab?

Mike Miller <mtmiller>
Project Administrator
Thu 17 Nov 2016 03:25:54 PM UTC, comment #3: 

I believe the following changeset improves compatibility with Matlab

  http://hg.savannah.gnu.org/hgweb/octave/rev/9c6661004167

John W. Eaton <jwe>
Project Administrator
Wed 16 Nov 2016 08:20:31 PM UTC, comment #2: 

This example still behaves the same way in Octave 4.2 and the development version. Can someone with access to a current version of Matlab confirm that this is a compatibility issue? Does a script file with a "break" command in it break out of a loop in the calling script?

Mike Miller <mtmiller>
Project Administrator
Wed 05 Jun 2013 03:36:20 PM UTC, comment #1: 

The word "subroutine" is ambiguous here. We don't use it when talking about Octave. The point is that you're running a script file, not a function file, and script files don't create scopes, so if they have a break command in them, it should refer to the scope of where they were called from.

Jordi GutiƩrrez Hermoso <jordigh>
Project Administrator
Wed 05 Jun 2013 08:42:11 AM UTC, original submission:  

when a main file with a loop calls a subroutine with "break" command, the command doesn't affect the loop of main file. It should exit from the loop, but it only exits from the second file.

For example: if we have 2 m files "Main.m" and "Subroutine.m" like these:
Main:

for k=1:3
        k
        Subroutine
        disp('Loop finished')
endfor

Subroutine:

if k==2
         break
endif
disp('Subroutine finished')

Now if we run "Main" the result will be:

k = 1.00
Subroutine finished
Loop finished
k = 2.00
Loop finished
k = 3.00
Subroutine finished
Loop finished

Now if we replace "break" with "continue" in "Subroutine" and run "Main" again we have:

k = 1.00
Subroutine finished
Loop finished
k = 2.00
k = 3.00
Subroutine finished
Loop finished

Rouhollah <paryshaan>

 

(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)
  • -email is unavailable- added by jordigh (Posted a comment)
  • -email is unavailable- added by paryshaan (Submitted the item)
  •  

    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 project members can vote.

     

     

     

     

    Follow 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-11-17 mtmiller StatusNeed Info Fixed
        Open/ClosedOpen Closed
    2016-11-16 mtmiller Severity3 - Normal 2 - Minor
        Priority5 - Normal 3 - Low
        StatusConfirmed Need Info
        Release3.6.4 dev
        Summary"break" in script has no effect on loop in main. break command at top-level in script has no effect on loop in calling context
    2013-06-05 jordigh StatusNone Confirmed
        Operating SystemMicrosoft Windows Any
        Summary"break" in subroutine has no effect on loop in main. "break" in script has no effect on loop in main.

    Back to the top


    Powered by Savane 3.9