fieldnames(foo) vs. for [v k]=foo

View: New views
2 Messages — Rating Filter:   Alert me  

fieldnames(foo) vs. for [v k]=foo

by Muhali :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Setting

octave> foo.b = pi ; foo.a = pi ;

one gets

octave> disp(fieldnames (foo))
{
  [1,1] = b
  [2,1] = a
}

but

octave> for [v k] = foo, disp(k), endfor
a
b

So `for' uses lexicographic ordering while `fieldnames' uses assignment order. Isn't that inconsequent, or at least somewhat confusing?

fieldnames(foo) vs. for [v k]=foo

by John W. Eaton-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On  5-Aug-2009, Muhali wrote:

| Setting
|
| octave> foo.b = pi ; foo.a = pi ;
|
| one gets
|
| octave> disp(fieldnames (foo))
| {
|   [1,1] = b
|   [2,1] = a
| }
|
| but
|
| octave> for [v k] = foo, disp(k), endfor
| a
| b
|
| So `for' uses lexicographic ordering while `fieldnames' uses assignment
| order. Isn't that inconsequent, or at least somewhat confusing?

I checked in the following change.

  http://hg.savannah.gnu.org/hgweb/octave/rev/ca95d991a65a

BTW, it's best to report bugs on the bug@... list.

Thanks,

jwe
_______________________________________________
Help-octave mailing list
Help-octave@...
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave