octave-maintainers
[Top][All Lists]
Advanced

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

Re: Error with pkg.m (== isspace does work with cell arrays anymore)


From: Søren Hauberg
Subject: Re: Error with pkg.m (== isspace does work with cell arrays anymore)
Date: Mon, 25 Feb 2008 22:46:21 +0100

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."

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.

Søren



reply via email to

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