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

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

[Octave-bug-tracker] [bug #56167] non-existent cell indexing 'C{}' shoul


From: Rik
Subject: [Octave-bug-tracker] [bug #56167] non-existent cell indexing 'C{}' should produce an error
Date: Fri, 19 Apr 2019 13:12:58 -0400 (EDT)
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko

Update of bug #56167 (project octave):

              Item Group:        Unexpected Error => Missed Error or Warning
                 Summary: non-existent cell indexing within matrix brackets
results in concatenation error => non-existent cell indexing 'C{}' should
produce an error

    _______________________________________________________

Follow-up Comment #9:

The syntax of indexing without providing an actual index is not a good coding
practice.  First, it is unclear what is intended and it relies on a specific
side effect that empty indexing '{}' is equivalent to colon indexing '{:}'. 
Better to simply write '{:}' if that is what the code should do.  Second, it
makes the code platform-specific to Octave.  Matlab does not support this
syntax.

The Octave motto is "Free Your Numbers" because you should be able to run code
you write on whatever OS (Linux, Mac, Windows) you want and with whatever
interpreter you like (Octave, Matlab).  Writing code that will only work with
an Octave side effect seems like it is a step backwards.

So, I agree with Andrew that Octave should produce an error for this syntax. 
I chaged the title to reflect that.

The second question is whether Octave should allow concatenation of empty
arrays that differ in size.  When the arrays are not-empty this clearly is an
error


[zeros(2,1), zeros(2,1), 1]
error: horizontal dimensions mismatch (2x2 vs 1x1)


But if they are empty, should they just be ignored completely?


octave:1> [zeros(0,1), zeros(0,1), 1]
error: horizontal dimensions mismatch (0x2 vs 1x1)


Not that we have to follow Matlab, but they currently allow this syntax, but
warn that is will be removed.

The warning is


Warning: this concatenation operation includes an empty array with an
incorrect number of rows.
Concatenation including empty arrays will require all arrays to have the same
number of rows in a future release.


I'm guessing it might be good for Octave to support this, with a warning like
Matlab, because there is probably m-file code developed over the last 25 years
that expects this behavior.


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?56167>

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




reply via email to

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