[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #45835] wrong scope may be used in anonymous f
From: |
Rik |
Subject: |
[Octave-bug-tracker] [bug #45835] wrong scope may be used in anonymous function evaluation |
Date: |
Sat, 29 Aug 2015 13:59:06 +0000 |
User-agent: |
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1) |
Update of bug #45835 (project octave):
Status: Need Info => Confirmed
_______________________________________________________
Follow-up Comment #8:
Very deep in the weeds. I had no idea functions like __current_scope__
existed. I corrected the function name in the docstring and added a one-line
definition here (http://hg.savannah.gnu.org/hgweb/octave/rev/33b03b06442b).
Attached is a little m-file mainfcn.m which shows how scope and context change
with a function, subfunction, nested function and recursion--useful for
learning.
Function is
function mainfcn ()
persistent recurse_count = 0;
[s1, c1] = __current_scope__ ();
printf ("Scope, Context in main function: %d, %d\n", s1, c1);
subfcn ();
function nestfcn ()
[s3, c3] = __current_scope__ ();
printf ("Scope, Context in nested function: %d, %d\n", s3, c3);
endfunction
nestfcn ();
printf ("------------------------------------------------------------\n");
if (recurse_count++ < 5)
mainfcn ();
else
return;
endif
endfunction
function subfcn ()
[s1, c1] = __current_scope__ ();
printf ("Scope, Context in subfunction: %d, %d\n", s1, c1);
endfunction
Output is
octave:1> mainfcn
Scope, Context in main function: 58, 0
Scope, Context in subfunction: 60, 0
Scope, Context in nested function: 59, 0
------------------------------------------------------------
Scope, Context in main function: 58, 1
Scope, Context in subfunction: 60, 0
Scope, Context in nested function: 59, 0
------------------------------------------------------------
Scope, Context in main function: 58, 2
Scope, Context in subfunction: 60, 0
Scope, Context in nested function: 59, 0
------------------------------------------------------------
Scope, Context in main function: 58, 3
Scope, Context in subfunction: 60, 0
Scope, Context in nested function: 59, 0
------------------------------------------------------------
Scope, Context in main function: 58, 4
Scope, Context in subfunction: 60, 0
Scope, Context in nested function: 59, 0
------------------------------------------------------------
Scope, Context in main function: 58, 5
Scope, Context in subfunction: 60, 0
Scope, Context in nested function: 59, 0
------------------------------------------------------------
(file #34765)
_______________________________________________________
Additional Item Attachment:
File name: mainfcn.m Size:0 KB
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?45835>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #45835] inconsistent behaviour of eval inside anonymous functions, anonymous, 2015/08/27
- [Octave-bug-tracker] [bug #45835] inconsistent behaviour of eval inside anonymous functions, Rik, 2015/08/27
- [Octave-bug-tracker] [bug #45835] inconsistent behaviour of eval inside anonymous functions, Mike Miller, 2015/08/27
- [Octave-bug-tracker] [bug #45835] interpreter does not search for anonymous function variables within a string, Rik, 2015/08/27
- [Octave-bug-tracker] [bug #45835] interpreter does not search for anonymous function variables within a string, John W. Eaton, 2015/08/28
- [Octave-bug-tracker] [bug #45835] wrong scope may be used in anonymous function evaluation, John W. Eaton, 2015/08/28
- [Octave-bug-tracker] [bug #45835] wrong scope may be used in anonymous function evaluation, John W. Eaton, 2015/08/28
- [Octave-bug-tracker] [bug #45835] wrong scope may be used in anonymous function evaluation, John W. Eaton, 2015/08/29
- [Octave-bug-tracker] [bug #45835] wrong scope may be used in anonymous function evaluation,
Rik <=
- [Octave-bug-tracker] [bug #45835] wrong scope may be used in anonymous function evaluation, Rik, 2015/08/29
- [Octave-bug-tracker] [bug #45835] wrong scope may be used in anonymous function evaluation, Rik, 2015/08/30