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

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

[Octave-bug-tracker] [bug #50893] for loop index variable not initialize


From: Rik
Subject: [Octave-bug-tracker] [bug #50893] for loop index variable not initialized unless loop is entered
Date: Fri, 28 Apr 2017 16:46:24 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0

Follow-up Comment #6, bug #50893 (project octave):

Trying to summarize.  It appears there are three incompatibilities.

1) When an object has columns, but no rows, Octave iterates over the columns
while Matlab does not iterate.  Sample code


for k = zeros (0,3)
  disp ('Hello');
end
Hello
Hello
Hello


2) When an object has rows, but no columns, Octave skips loop variable
assignment entirely.  Matlab assigns to the loop variable, but does not
execute the loop.  An object with no columns can be an empty range (3:0) or a
directly created object like zeros (3, 0).  Sample code 


clear k;
for k = zeros (3, 0)
  disp ('Hello');
end
whos k


3) In case 2 above, Matlab always creates a 0x0 double initialization for the
loop variable even when the object was a different type

clear k;
for k = zeros (3, 0, 'int32')
  disp ('Hello');
end
whos k

I think it is enough to fix items 1 and 2, but skip 3.



    _______________________________________________________

Reply to this item at:

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

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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