octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #56318] deal: invalid assignment to cs-list ou


From: Rik
Subject: [Octave-bug-tracker] [bug #56318] deal: invalid assignment to cs-list outside multiple assignment
Date: Mon, 13 May 2019 12:36:04 -0400 (EDT)
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko

Update of bug #56318 (project octave):

              Item Group:        Unexpected Error => Matlab Compatibility   
                  Status:                    None => Confirmed              

    _______________________________________________________

Follow-up Comment #1:

Confirmed.  Changing item group to "Matlab Compatibility" since Octave does
allow for multiple assignment, but with different semantics from Matlab.

Either of these scalar assignments work in Octave or Matlab.


A = struct ('a', 1);
[A(:).a] = 0
[A(:).a] = deal (3)


Similarlay, when the struct array is not scalar, then scalar assignment fails
but deal() works.


A(2).a = pi;
[A(:).a] = 45;         % This fails in Octave and Matlab
[A(:).a] = deal (45);  % This works in Octave and Matlab


However, when the field does not exist, Octave produces an error, while Matlab
goes ahead and creates the new field, and then performs assignment.  This is
the original case


A = struct ('a', 1);
[A(:).b] = deal (0);


If you use the debugger you can step through the deal.m function and find that
it returns a scalar, cell array.  For the code above, the interpreter is
seeing


[A(:).b] = {0};


In most cases of assignment, the left-hand side has a fixed size, or it is a
new variable and so size is unimportant.  For example, the assignment


[d(:)] = 5


succeeds presumably because the interpreter detects that d does not exist and
so there doesn't need to be any size checks.

Adding jwe since he is the only one who knows, probably, where to begin on
this one.


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?56318>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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