octave-maintainers
[Top][All Lists]
Advanced

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

Re: Structures 6.1.1 Basic Usage and Examples


From: Julien Bect
Subject: Re: Structures 6.1.1 Basic Usage and Examples
Date: Tue, 13 May 2014 16:39:58 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.2.0

Le 13/05/2014 16:15, Mike Miller a écrit :
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.

Since it is now clear that this is a design decision in Octave and not a bug, I think that bug #32381 should be closed.




reply via email to

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