[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Puzzled about scope/existence of globals
From: |
Glenn Golden |
Subject: |
Puzzled about scope/existence of globals |
Date: |
Sat, 22 Nov 2003 17:26:02 -0700 |
Given the function foo(), defined as
function foo()
global g;
exist("g", "var")
endfunction
I found the following to be surprising:
1> foo
ans = 0 # ok
2> global g
3> g.barf = 1;
4> foo
ans = 1 # ok
5> clear g
6> whos g
# ok
7> foo
ans = 1 # huh?
Perhaps this is expected behavior, but I don't understand it.
Can someone explain the rules regarding scope and existence
of globals in a circumstance like this?
Thanks,
- Glenn
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
- Puzzled about scope/existence of globals,
Glenn Golden <=
Re: Puzzled about scope/existence of globals, Tomer Altman, 2003/11/22