field ordering in octave's save/load
Sergei Steshenko
sergstesh at yahoo.com
Tue Mar 3 21:14:30 CST 2009
--- On Tue, 3/3/09, Gunnar Rätsch <Gunnar.Raetsch at tuebingen.mpg.de> wrote:
> From: Gunnar Rätsch <Gunnar.Raetsch at tuebingen.mpg.de>
> Subject: field ordering in octave's save/load
> To: bug at octave.org
> Date: Tuesday, March 3, 2009, 12:39 PM
> Dear octave team,
>
> I've been using octave a lot recently and am really
> happy with its
> recent progress. Thanks a lot for your efforts!
>
> I came across one issue today, which isn't really a
> bug, but just a
> different behaviour compared to matlab, which you may want
> to fix (at
> least it would help me quite a bit).
> I've noticed that when structures are saved and then
> loaded again in
> octave, then the fields are alphabetically sorted. This is
> not the
> case in matlab.
> I had a piece of code that depended on the ordering of
> these fields
> and therefore the octave code failed, while the matlab code
> worked
> just fine (this was a difficult-to-find bug).
>
> What do you think? Do you intend to change the code such
> that the
> field order is preserved?
>
> Thanks a lot in advance,
>
> Gunnar
>
IIRC, structs are hashes, struct fields are hash keys, and typically hash
keys order cannot be relied upon, i.e. one has to use a special (not the
simplest) implementation of hashes in order to preserve hash keys order.
So, does Matlab promise hash keys order in your scenario ?
If yes, then it's a bug in 'octave', if not - then it's a bug in your code
- it relies on an undocumented feature.
Regards,
Sergei.
More information about the Bug-octave
mailing list