[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #60850] Using (end+1) on non-existent variable
From: |
Rik |
Subject: |
[Octave-bug-tracker] [bug #60850] Using (end+1) on non-existent variable assignment fails in Octave 6.2.0 |
Date: |
Tue, 29 Jun 2021 11:58:47 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.101 Safari/537.36 |
Update of bug #60850 (project octave):
Category: None => Interpreter
Item Group: Regression => Matlab Compatibility
Operating System: GNU/Linux => Any
_______________________________________________________
Follow-up Comment #1:
The behavior of Octave now matches Matlab. The special index 'end' is
supposed to refer to the last element of an array. If the array does not
exist then one interpretation is that a last index can therefore not exist.
This is the position that Matlab takes and which Octave now implements.
A different interpretation would be that the 'end' index should always be
valid. But, it quickly gets complicated. For example,
clear all
a(end) = 1
b(end+1) = 2
In the first case, 'end' must be set internally equal to 1 by the interpreter
so that the variable 'a' is created with one element.
In the second case, should 'end' be equal to 0 or 1. If it is equal to 0 then
'end+1' = 1 and the variable 'b' will have one element. However, if 'end' is
equal to 1 then the statement will be
b(1+1) = 2
b(2) = 2
and the variable 'b' will have two elements.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?60850>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/