[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #55995] "continue" is dynamically, not lexical
From: |
Andrew Janke |
Subject: |
[Octave-bug-tracker] [bug #55995] "continue" is dynamically, not lexically scoped - callable from functions without for loops |
Date: |
Mon, 25 Mar 2019 03:42:25 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.75 Safari/537.36 |
URL:
<https://savannah.gnu.org/bugs/?55995>
Summary: "continue" is dynamically, not lexically scoped -
callable from functions without for loops
Project: GNU Octave
Submitted by: apjanke
Submitted on: Mon 25 Mar 2019 07:42:24 AM UTC
Category: Interpreter
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Other
Status: None
Assigned to: None
Originator Name:
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: 5.1.0
Operating System: Any
_______________________________________________________
Details:
In Octave, you can call "continue" from within a function that does not itself
contain a for loop, and it will either cause a continuation in a for loop in a
calling function, or do nothing.
Example:
looper.m:
function looper
for i = 1:5
fprintf ("before\n");
other_fcn ();
fprintf ("after\n");
end
end
other_fcn.m:
function other_fcn
continue
end
Output:
>> looper
before
before
before
before
before
>> continue
>> continue
>> continue
>> other_fcn
>> other_fcn
>>
Note that you can just call continue even if there's no for loop in the
enclosing dynamic scope, and it does nothing.
Is this expected behavior? I saw it discussed over in
https://savannah.gnu.org/bugs/?48665 related to a crash, but not mentioning
that the behavior itself is odd.
Break doesn't behave the same way: it raises an error if you try to call it
outside the lexical scope of a for loop.
call_break.m:
function call_break
break
endfunction
>> break
parse error:
break must appear in a loop in the same file as loop command
>>> break
^
>> call_break
parse error near line 2 of file /Users/janke/tmp/octave-continue/call_break.m
break must appear in a loop in the same file as loop command
>>> break
^
>>
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?55995>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #55995] "continue" is dynamically, not lexically scoped - callable from functions without for loops,
Andrew Janke <=
- [Octave-bug-tracker] [bug #55995] "continue" is dynamically, not lexically scoped - callable from functions without for loops, Andrew Janke, 2019/03/25
- [Octave-bug-tracker] [bug #55995] "continue" is dynamically, not lexically scoped - callable from functions without for loops, A.R. Burgers, 2019/03/25
- [Octave-bug-tracker] [bug #55995] "continue" is dynamically, not lexically scoped - callable from functions without for loops, Rik, 2019/03/25
- [Octave-bug-tracker] [bug #55995] "continue" is dynamically, not lexically scoped - callable from functions without for loops, John W. Eaton, 2019/03/25
- [Octave-bug-tracker] [bug #55995] "continue" is dynamically, not lexically scoped - callable from functions without for loops, Andrew Janke, 2019/03/25
- [Octave-bug-tracker] [bug #55995] "continue" is dynamically, not lexically scoped - callable from functions without for loops, John W. Eaton, 2019/03/26
- [Octave-bug-tracker] [bug #55995] "continue" is dynamically, not lexically scoped - callable from functions without for loops, John W. Eaton, 2019/03/26
- [Octave-bug-tracker] [bug #55995] "continue" is dynamically, not lexically scoped - callable from functions without for loops, Andrew Janke, 2019/03/26
- [Octave-bug-tracker] [bug #55995] "continue" is dynamically, not lexically scoped - callable from functions without for loops, Rik, 2019/03/26
- [Octave-bug-tracker] [bug #55995] "continue" is dynamically, not lexically scoped - callable from functions without for loops, John W. Eaton, 2019/03/26