Add seealso strings to list- related functions.

Søren Hauberg soren at hauberg.org
Wed Jan 16 01:16:57 CST 2008


tir, 15 01 2008 kl. 18:03 -0500, skrev John W. Eaton:
> On 14-Jan-2008, Muthiah Annamalai wrote:
> 
> | Again, turns out I was mistaken. I wrote code like,
> | 
> | x = dir();
> | 
> | x.name(1)
> | x.isdir(1)
> | 
> | etc, which werent working. I must have used x(1).name, x(1).isdir etc
> | which is the correct way, I learnt on seeing dir.m
> | 
> | I used x.name, x.isdir by converting them to lists, and such. Which is
> | why I had this convoluted way of reasoning it may help.
> 
> Given a struct array like X above,
> 
>   x.field
> 
> produces a comma-separated list, which is different from a list
> object.  A comma-separated list can only be displayed, used as an
> argument list for another function, or used to construct a cell array
> or matrix with the {} or [] operators.
> 
> Maybe we should change the way comma-separated lists are displayed to
> help avoid the confusion.
There is also a matlab compatibility problem with the comma-separated
listed (I think). In Octave you can't assign a comma-separated list to a
variable (it produces an error) while you (to some extend) can in
matlab, although the variable will only contain the first element of the
list.

Octave:

  a = dir();
  b = a.name;
  error: invalid assignment of comma-separated list
  error: evaluating assignment expression near line 4, column 3

Matlab:

  a = dir;
  length(a)
  ans =
   150
  b = a.name
  b =
   .

That is, b contains the string '.'. So, for compatibility, I think more
than the way cs-lists are printed needs to be changed :-(

Søren

  




More information about the Bug-octave mailing list