help-octave
[Top][All Lists]
Advanced

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

Re: Display order of structure elements changed in 2.9.7


From: John W. Eaton
Subject: Re: Display order of structure elements changed in 2.9.7
Date: Thu, 28 Sep 2006 13:08:15 -0400

On 27-Sep-2006, David Bateman wrote:

| Benjamin Lindner wrote:
| > Hello list,
| >
| > I noticed a difference in the display order of structure elements in octave 
2.9.7 compared to 2.9.6 and 2.1.73.
| > 
| > [...]
| > 
| > Is this change intentional?
| > I did a look into the changelog file but did not find a hint concerning 
this.
| >
| > I know, the octave manual states that octave may print the elements of 
structures in any order (so basically one should not rely on a specific order), 
but - frankly said - I found the old behaviour of listing in alphabetical order 
very useful. it makes it much more user-friendly to read listings - especially 
if there are a large number of elements.
| >
| > Is there a chance to get the old behaviour back?
| > Or - assuming that there is of course a good reason for the new behaviour - 
could one introduce an option to enable/disable alphabetic sorting? e.g. a 
builtin variable like struct_display_sort_order having either "alphabetic" and 
a second option?
| >
| > benjamin
| >
| >   
| Trying this under matlab R2006a I get
| 
| >> A.d=1; A.b=2; A.c=3; A.a=4
| 
| A =
| 
|     d: 1
|     b: 2
|     c: 3
|     a: 4
| 
| seems its one of those stupidities to be compatiable with matlab. The
| patch that affected this was  "cvs diff -r 1.73 -r 1.74
| src/ov-struct.cc" and the Changelog entry is
| 
| 2006-07-06  John W. Eaton  <address@hidden>
| 
|         * ov-struct.cc (octave_struct::print_raw): Print keys in key_list
|         order.
| 
| Given, the matlab compatibility is considered more important that
| compatibility with older versions of octave, I don't imagine this will
| be changed...

Yes, the change was intentional.  We need the key_list order so that
MEX files work properly.  Using the MEX interface, Matlab allows the
elements to be indexed numerically in the order they are added.  So it
makes sense to also display them in this order.

Previously, there was no order imposed, other than by the way the
std::map class stored keys.  Since that order was dependent on a hash
function, it could be anything, and hashing algorithm used in one C++
library could be different from another.

In any case, since this is just a display issue, I think it should
also be OK to have an option to display the keys in an alphabetized
order. This option should be controlled by an internal variable,
manipulated by a function.  I'd consider a patch.

jwe


reply via email to

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