From bug-octave-request at bevo dot che dot wisc dot edu Thu Mar 18 12:51:39 2004 Subject: Re: global /exist ? From: Christoph Ellenberger To: paulthomas2 at wanadoo dot fr, bug-octave@bevo.che.wisc.edu Date: Thu, 18 Mar 2004 19:36:50 +0100 Hi Paul T, on the other hand one part of the program has to be the first to declare it= =20 global and initialize, and so a construction like: global xx if (!exist("xx")) init xx; endif in a modular environment may make sense... PS. I missed this discussion so there might be already some counter argumen= t=20 about that. BTW and you are right if you say one can also write something like: global xx if isempty(xx) init xx; endif but then xx is not allowed to be in an empty state.... =20 Sometimes one just has to make compromises :) Christoph On Thursday 18 March 2004 16:42, Paul THOMAS wrote: > Hi Christoph, > > It seems to me that not only is this a compatability issue but a logical > one as well. There was a discussion some months ago about how global > functions, although I do not recall on which list. It seems to me that > making a variable global must mean that it exists in the current scope, > otherwise what would be the meaning to other scopes? Thus, making global > an implicit constructor of an empty matrix, if there is not already a > global variable with that name, or a variable local to the current scope, > is logically mandatory. > > Paul T > > > Message du 16/03/04 12:39 > > De : Christoph Ellenberger > > A : bug-octave at bevo dot che dot wisc dot edu > > Copie =E0 : > > Objet : global /exist ? > > > > Hi, > > this just occured to me... using the latest 2.1.57. I dunno if it is a > > bug or intended. > > > > octave:1> exist("hh") > > ans =3D 0 > > octave:2> global hh > > octave:3> exist("hh") > > ans =3D 1 > > > > even if hh is not existing as a global variable... > > further hh is now initialised as a matrix. > > octave:4> hh > > hh =3D [](0x0) > > > > AFAIK this breaks the behaviour of precedent versions at least (2.1.50). > > > > Greetings > > Christoph > > > > > > > > ------------------------------------------------------------- > > 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 > > ------------------------------------------------------------- =2D-=20 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= ... =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (o = o) =2D----------------------oOO--(_)--OOo-------------------------- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 present coordinates: Christoph Ellenberger =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0Solid State Physics Laboratory HPF E9 Schaffhauserstrasse 443 =A0 =A0 =A0 ETH Hoenggerberg CH-8050 Zuerich =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 CH-8093 Zuerich Tel ++41 (0)43 299 92 72 =A0 =A0 =A0 =A0(0)1 633 23 13 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Email =A0 C dot Ellenberger at gmx dot net =2D--------------------------------------------------------------------- ------------------------------------------------------------- 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 -------------------------------------------------------------