[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #33533] strvcat Matlab compatibility issue
From: |
Rik |
Subject: |
[Octave-bug-tracker] [bug #33533] strvcat Matlab compatibility issue |
Date: |
Thu, 28 Jul 2011 03:25:25 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:5.0) Gecko/20100101 Firefox/5.0 |
Follow-up Comment #6, bug #33533 (project octave):
I'm not certain this is the correct fix. According to the documentation
(http://www.mathworks.com/help/techdoc/ref/strvcat.html) strvcat can operate
on (strings or char arrays) or (cellstrs).
The example given by the issue reporter
a = {};
strvcat(a{:})
is really an empty cell array and not an emtpy cellstr array. Thus, I would
like Octave to error out and tell me that I am feeding it incorrect inputs.
Feeding an empty cellstr array to strvcat, by contrast, does not generate an
error.
a = {""};
strvcat(a{:})
In general, Matlab's philosophy seems to be less stringent in checking its
inputs. That's fine, but it is a design choice that Octave hasn't followed in
the past. In fact, I try and add input validation to functions whenever I can
to avoid Garbage In/Garbage Out. In this case, I don't think it makes sense
to have a one-off exception to Octave's coding philosophy.
Also, if we decide to keep the new changeset then, at a minimum, strcat() and
char() need to be changed to accept empty cell arrays.
To address the reporter's concern. It is still easy to write portable code by
using isempty().
if (! isempty (a))
b = strvcat (a{:})
endif
OR if you're tight for space and like one-liners
! isempty (a) && (b = strvcat (a{:}));
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?33533>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #33533] strvcat Matlab compatibility issue, Rik, 2011/07/27
- [Octave-bug-tracker] [bug #33533] strvcat Matlab compatibility issue, Arnaud Delorme, 2011/07/27
- [Octave-bug-tracker] [bug #33533] strvcat Matlab compatibility issue, Jordi Gutiérrez Hermoso, 2011/07/27
- [Octave-bug-tracker] [bug #33533] strvcat Matlab compatibility issue, Arnaud Delorme, 2011/07/27
- [Octave-bug-tracker] [bug #33533] strvcat Matlab compatibility issue, Jordi Gutiérrez Hermoso, 2011/07/27
- [Octave-bug-tracker] [bug #33533] strvcat Matlab compatibility issue,
Rik <=
- [Octave-bug-tracker] [bug #33533] strvcat Matlab compatibility issue, Arnaud Delorme, 2011/07/27
- [Octave-bug-tracker] [bug #33533] strvcat Matlab compatibility issue, Jordi Gutiérrez Hermoso, 2011/07/28
- [Octave-bug-tracker] [bug #33533] strvcat Matlab compatibility issue, Arnaud Delorme, 2011/07/28
- [Octave-bug-tracker] [bug #33533] strvcat Matlab compatibility issue, Jordi Gutiérrez Hermoso, 2011/07/28
- [Octave-bug-tracker] [bug #33533] strvcat Matlab compatibility issue, Arnaud Delorme, 2011/07/28
- [Octave-bug-tracker] [bug #33533] strvcat Matlab compatibility issue, Jordi Gutiérrez Hermoso, 2011/07/29