octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #54052] the global statement clears previously


From: Mike Miller
Subject: [Octave-bug-tracker] [bug #54052] the global statement clears previously assigned values
Date: Mon, 4 Jun 2018 15:04:16 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0

Follow-up Comment #3, bug #54052 (project octave):

Can someone with access to Matlab test what the behavior is when a global is
declared for the first time with the same name as a local variable that has
already been initialized? It's unclear whether this is a Matlab compatibility
issue until we see how Matlab actually behaves.

The way I read the docs, they are only describing what happens if you already
have a global named "x" with a value, and a local variable in a different
scope with its own different value. For example


function declareit (value)
  global x;
  x = value;
end

>> declareit (42)
>> x
error: 'x' undefined near line 1 column 1
>> x = 12
x =  12
>> global x
>> x
x =  42



This is the correct behavior and is Matlab compatible according to those docs.
The remaining question is what happens if x has not yet been declared global
in any scope.

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?54052>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]