On Tue, May 13, 2014 at 15:48:53 +0200, Julien Bect wrote:
The example from Octave's documentation :
x.a = 1;
x.b = [1, 2; 3, 4];
x.c = "string";
x.b.d = 3;
runs without even a warning in both Matlab R2012a and Matlab R2013a.
The example from the older bug report :
x = 1;
x.a = 2;
also results in overwriting the scalar value 1.0 with a structure, but this
time with a warning :
??? Warning: Struct field assignment overwrites a value with class
"double".
See MATLAB 7.0.4 Release Notes, Assigning Nonstructure Variables As
Structures Displays Warning for details.
I don't know about R2013b or R2014a.
Both examples currently fail in Octave (with a different error, though).
Unless Matlab's behaviour has recently changed, I would say this is a bug in
the code, not in the documentation.
Based on that warning message, and what I have found online, it looks
to me like this kind of assignment is deprecated in Matlab. Version
7.0.4 (2005) introduced this warning and it's apparently still warning
in current versions. This is probably why this change was made to
Octave, although making it an error instead of allowing with a
warning.
This was definitely changed intentionally in Octave 3.4 and was
announced when it was done. Excerpt from etc/NEWS.3:
** The behavior of struct assignments to non-struct values has been
changed. Previously, it was possible to overwrite an arbitrary
value:
a = 1;
a.x = 2;
This is no longer possible unless a is an empty matrix or cell
array.
Looks to me like these two changesets:
* http://hg.savannah.gnu.org/hgweb/octave/rev/333bf09e3b6e
* http://hg.savannah.gnu.org/hgweb/octave/rev/8f17e3309a82
That's all the information I have about it. My best guess is it was
changed this way because Matlab decided to deprecate that behavior in
2005. Octave is just being stricter about it. Doesn't seem worth it to
me to reintroduce deprecated behavior that has been an error in Octave
for 3 years now without any reported problems.