[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #60845] Nested functions variable scope
From: |
Rik |
Subject: |
[Octave-bug-tracker] [bug #60845] Nested functions variable scope |
Date: |
Mon, 28 Jun 2021 17:04:11 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.101 Safari/537.36 |
Update of bug #60845 (project octave):
Status: None => Confirmed
_______________________________________________________
Follow-up Comment #1:
Confirmed. Thank you for the minimal example. I added a keyboard statement
at the start of nestfcn(). I then executed 'who' to see what variables were
available. The results are odd.
Variables visible from the current scope:
Ahandle Ahandle fcn_handle static varargin Ahandle
fcn_handle static varargin
As you can see, the variable "Ahandle" is repeated 3 times while other
variables are still repeated twice. Within a given scope, I should see only
one instance of a variable so something is wrong.
I then tried 'whos' which maybe helps sort things out a bit.
Variables visible from the current scope:
variables in scope: nestfcn:
/home/rik/wip/Projects_Mine/octave-dev/mainfcn2.m
Attr Name Size Bytes Class
==== ==== ==== ===== =====
Ahandle 1x1 0 function_handle
Total is 1 element using 0 bytes
variables in scope: checkInput:
/home/rik/wip/Projects_Mine/octave-dev/mainfcn2.m
Attr Name Size Bytes Class
==== ==== ==== ===== =====
f Ahandle 1x1 1 logical
f fcn_handle 1x1 0 function_handle
f static 1x1 1 logical
f varargin 0x0 0 cell
Total is 3 elements using 2 bytes
variables in scope: mainfcn2:
/home/rik/wip/Projects_Mine/octave-dev/mainfcn2.m
Attr Name Size Bytes Class
==== ==== ==== ===== =====
Ahandle 1x1 1 logical
fcn_handle 1x1 0 function_handle
static 1x1 1 logical
f varargin 0x0 0 cell
Total is 3 elements using 2 bytes
Apparently, with just 'who' I am seeing variables for all scopes, regardless
of whether they are really available or not. Given that I am in the function
nestfcn I don't know why I should see variables for the checkInput() scope. I
verified with dbstack where I was
dbstack
stopped in:
--> mainfcn2>nestfcn at line 15
[/home/rik/wip/Projects_Mine/octave-dev/mainfcn2.m]
mainfcn2 at line 4
[/home/rik/wip/Projects_Mine/octave-dev/mainfcn2.m]
(file #51614)
_______________________________________________________
Additional Item Attachment:
File name: mainfcn2.m Size:0 KB
<https://file.savannah.gnu.org/file/mainfcn2.m?file_id=51614>
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?60845>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #60845] Nested functions variable scope, José Matos, 2021/06/28
- [Octave-bug-tracker] [bug #60845] Nested functions variable scope,
Rik <=
- [Octave-bug-tracker] [bug #60845] Nested functions variable scope when varargin is present, Rik, 2021/06/28
- [Octave-bug-tracker] [bug #60845] Nested functions variable scope when varargin is present, Rik, 2021/06/28
- [Octave-bug-tracker] [bug #60845] Nested functions variable scope when varargin is present, Rik, 2021/06/28
- [Octave-bug-tracker] [bug #60845] Variables in nested functions exhibit multiple problems, Rik, 2021/06/28
- [Octave-bug-tracker] [bug #60845] Variables in nested functions exhibit multiple problems, José Matos, 2021/06/28
- [Octave-bug-tracker] [bug #60845] Variables in nested functions exhibit multiple problems, Rik, 2021/06/28
- [Octave-bug-tracker] [bug #60845] Variables in nested functions exhibit multiple problems, Rik, 2021/06/28
- [Octave-bug-tracker] [bug #60845] Variables in nested functions exhibit multiple problems, John W. Eaton, 2021/06/29
- [Octave-bug-tracker] [bug #60845] Variables in nested functions exhibit multiple problems, John W. Eaton, 2021/06/29
- [Octave-bug-tracker] [bug #60845] Variables in nested functions exhibit multiple problems, Rik, 2021/06/29