[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #51698] Nested function fails to inherit a var
From: |
John W. Eaton |
Subject: |
[Octave-bug-tracker] [bug #51698] Nested function fails to inherit a variable created with assignin |
Date: |
Wed, 9 Aug 2017 14:07:23 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0 |
Follow-up Comment #9, bug #51698 (project octave):
The problem is that assignin (or eval, or load) can create variables. That
causes trouble for lookup of non-local names. If you want things to work
properly, then write it like this:
function main();
M = [];
_setM();
(do stuff with M here)
K = 2;
_callsub_on_K();
function _callsub();
K +=3 ;
endfunction
endfunction
function _setM();
assignin("caller", "M", 1);
endfunction
But I have to ask, why do you want to use assignin here instead of just
writing
function main();
M = _setM ();
(do stuff with M here)
K = 2;
_callsub_on_K();
function _callsub();
K +=3 ;
endfunction
endfunction
function M = _setM();
M = 1;
endfunction
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?51698>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #51698] Nested function fails to inherit a variable, anonymous, 2017/08/09
- [Octave-bug-tracker] [bug #51698] Nested function fails to inherit a variable, anonymous, 2017/08/09
- [Octave-bug-tracker] [bug #51698] Nested function fails to inherit a variable, John W. Eaton, 2017/08/09
- [Octave-bug-tracker] [bug #51698] Nested function fails to inherit a variable created with assignin, John W. Eaton, 2017/08/09
- [Octave-bug-tracker] [bug #51698] Nested function fails to inherit a variable created with assignin, John W. Eaton, 2017/08/09
- [Octave-bug-tracker] [bug #51698] Nested function fails to inherit a variable created with assignin, anonymous, 2017/08/09
- [Octave-bug-tracker] [bug #51698] Nested function fails to inherit a variable created with assignin, John W. Eaton, 2017/08/09
- [Octave-bug-tracker] [bug #51698] Nested function fails to inherit a variable created with assignin, anonymous, 2017/08/09
- [Octave-bug-tracker] [bug #51698] Nested function fails to inherit a variable created with assignin, anonymous, 2017/08/09
- [Octave-bug-tracker] [bug #51698] Nested function fails to inherit a variable created with assignin,
John W. Eaton <=
- [Octave-bug-tracker] [bug #51698] Nested function fails to inherit a variable created with assignin, anonymous, 2017/08/09
- [Octave-bug-tracker] [bug #51698] Nested function fails to inherit a variable created with assignin, John W. Eaton, 2017/08/11
- [Octave-bug-tracker] [bug #51698] Nested function fails to inherit a variable created with assignin, Colin Macdonald, 2017/08/21