[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #43813] Edge case in indexing rules does not w
From: |
jose |
Subject: |
[Octave-bug-tracker] [bug #43813] Edge case in indexing rules does not work as in Matlab |
Date: |
Sat, 13 Dec 2014 15:19:12 +0000 |
User-agent: |
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0 |
URL:
<http://savannah.gnu.org/bugs/?43813>
Summary: Edge case in indexing rules does not work as in
Matlab
Project: GNU Octave
Submitted by: josombio
Submitted on: Sat 13 Dec 2014 15:19:12 GMT
Category: Interpreter
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Matlab Compatibility
Status: None
Assigned to: None
Originator Name: José
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: 3.8.2
Operating System: GNU/Linux
_______________________________________________________
Details:
There as an edge case in indexing rules that is not handled as in Matlab. This
case is not officially documented in Matlab, but unofficially here
<http://stackoverflow.com/questions/4895556/how-to-wrap-a-function-using-varargin-and-varargout>
by SCFrench, an employee from The Mathworks.
According to SCFrench, the rule is (literaly):
When performing subscripted assignment, if
* subscripted-assigning to an uninitialized variable, AND
* the uninitialized variable is curly-brace indexed, AND
* the index in the curly braces is empty, AND
* the left-hand side appears inside square braces, AND
* the right-hand side resolves to a value / returns an output
Then the uninitialized variable is assigned a scalar cell containing the
value returned by the right-hand side.
The test: the following code, executed in Matlab
>> clear uninit % just to make sure uninit is uninitialized
>> [uninit{[]}] = sin(0)
uninit =
[0]
and in Octave 3.8.2
octave:142> clear uninit %
octave:143> [uninit{[]}] = sin(0)
uninit = {}(0x0)
This produces that the following function wrapper
function varargout = wrapper( varargin )
[varargout{1:nargout}] = someFunction( varargin{:} );
endfunction
does not return in Octave a result when the wrapper is called with no output
arguments when someFunction returns something even if no output arguments are
requested. This is shown in the following code
> [varargout{1:nargout}] = sin( varargin{:} );
> endfunction
octave:76> wrapper(0) %this should give ans = 0, and it does not.
octave:77> a=wrapper(0)
a = 0
octave:78> sin(0)
ans = 0
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?43813>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Octave-bug-tracker] [bug #43813] Edge case in indexing rules does not work as in Matlab,
jose <=