From bug-octave-request at bevo dot che dot wisc dot edu Mon Dec 13 23:25:04 1999 Subject: bug in loading files with global vars and in "global x = y" From: stevenj at gil-galad dot mit dot edu To: bug-octave at bevo dot che dot wisc dot edu Date: Mon, 13 Dec 1999 23:25:49 -0600 (CST) Dear Octave Maintainers, I have found a bug in Octave's handling of global variables. (This bug manifests itself in the latest CVS snapshot.) First of all, the construct "global x = y" doesn't work: octave> global g = "should be global" octave> is_global("g") ans = 0 You have to declare it as global separately, after it has been assigned a value: octave> global g octave> is_global("g") ans = 1 A similar problem manifests itself in saving/loading the variables: octave> save "g.save" Note that octave's native file format(s) save whether or not a variable is global. Now, if we quit Octave and start it again, we get: octave:1> load "g.save" octave:2> is_global("g") ans = 0 However, if we load a second time (with -force) it works: octave:3> load -force "g.save" octave:4> is_global("g") ans = 1 So, it seems that the bug is that both the load command and "global x = y" try to set a variable as global before it is defined, and that doesn't work. Setting an already-defined variable as global works. (I looked at the source code for load, and it certainly looks like it is trying to set the variable as global before assigning it a value. I assume that this worked at some point, so presumably something has changed about Octave's symbol table to break this behavior.) Cordially, Steven G. Johnson ----------------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.che.wisc.edu/octave/octave.html How to fund new projects: http://www.che.wisc.edu/octave/funding.html Subscription information: http://www.che.wisc.edu/octave/archive.html -----------------------------------------------------------------------