|
From: | anonymous |
Subject: | [Octave-bug-tracker] [bug #54490] Order of evaluation in assignment expression |
Date: | Sat, 11 Aug 2018 00:44:29 -0400 (EDT) |
User-agent: | Mozilla/5.0 (Windows NT 5.1; rv:51.0) Gecko/20100101 Firefox/51.0 |
URL: <http://savannah.gnu.org/bugs/?54490> Summary: Order of evaluation in assignment expression Project: GNU Octave Submitted by: None Submitted on: Sat 11 Aug 2018 04:44:28 AM UTC Category: Interpreter Severity: 3 - Normal Priority: 5 - Normal Item Group: Incorrect Result Status: None Assigned to: None Originator Name: rahnema1 Originator Email: Open/Closed: Open Discussion Lock: Any Release: 4.4.0 Operating System: GNU/Linux _______________________________________________________ Details: The expected behavior of the simple and multiple assignment should be the same but the following example shows they have different behavior: disp("Testing simple assignment:") clear; a(k=1) = (k=2); k # result : k = 1 disp("Testing multiple assignment:") clear [a(k=1)] = (k=2); k # result : k = 2 The example shows that order of evaluation in simple assignment is from right to left but in multiple assignment it is from left to right. Other example that can be tested in MATLAB shows that similar expressions produce different results: clear function out=test global k; k = 1; out = 3; end global k; disp("Testing simple assignment:") k = 2; a = [5 6]; a(k) = test(); a # result : a = [3 6] disp("Testing multiple assignment:") k = 2; a = [5 6]; [a(k)] = test(); a # result : a = [5 3] _______________________________________________________ Reply to this item at: <http://savannah.gnu.org/bugs/?54490> _______________________________________________ Message sent via Savannah https://savannah.gnu.org/
[Prev in Thread] | Current Thread | [Next in Thread] |