On 25-Feb-2008, Søren Hauberg wrote:
|
| man, 25 02 2008 kl. 16:17 -0500, skrev John W. Eaton:
| > On 24-Feb-2008, Michael Goffioul wrote:
| >
| > | I have an error with recent mercurial code, in pkg.m. It reduces to
| > | the fact that isspace does not work anymore on cell array of
| > | strings. The error occurs around line 1299:
| > |
| > | if (! all (isspace (filenames)))
| > |
| > | where filenames is a cell array of strings. I'm not sure what's
| > | the correct way to fix this.
| >
| > I could probably help if I knew what isspace should do for a cell
| > array. Matlab appears to do this:
| >
| > >> isspace ({' ', ' ', ' '})
| >
| > ans =
| >
| > 0 0 0
| >
| >
| > Which makes no sense to me. Is this behavior useful in some way that
| > I'm not seeing?
| It seems to be that matlab is doing something like
|
| function output = isspace(input)
| if (ischar(input))
| ...
| else
| output = zeros(size(input), "logical");
| endif
| endfunction
|
| As an example:
| isspace(@sin)
| returns 0. Does that make sense? Not in my mind. I think the logic is:
|
| "A space is part of a string, hence if the input is not a string, it
| is not a space."
Yes, probably an error is better.
| I don't think we should copy this. If people depend on this behaviour,
| then there's a pretty good chance of a bug in their code.
OK, isspace appears to be unique. Matlab doesn't seem to have the
other is* predicates, but it does have isstrprop, which lumps them all
in one function. I propose the following change. The added functions in
{Cell,ov-cell}.{h,cc} make writing the isstrprop function fairly
simple.
I would guess this still doesn't solve the isspace problem in pkg.m.
We need to know what the intent of the isspace call there is.