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

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

[Octave-bug-tracker] [bug #49389] inputParser changes order of Results s


From: Carnë Draug
Subject: [Octave-bug-tracker] [bug #49389] inputParser changes order of Results structure depending on order by which parameters are assigned
Date: Fri, 21 Oct 2016 11:24:22 +0000 (UTC)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0

Follow-up Comment #4, bug #49389 (project octave):

> It may be that Matlab always maintains struct keys in sorted order.

Matlab struct keys are ordered by insertion. But Results does not have values
inserted until parse is called. This is the same in Matlab
addParameter/addParamValue


>> p = inputParser ();
>> p.addParamValue ('a', 1);
>> p.addParamValue ('b', 2);
>> p.Results

ans = 

1x1 struct array with no fields.



The actual order of insertion is kept, in Parameters:


## Matlab
>> p.Parameters

ans = 

    'a'    'b'
## Octave
octave-gui:4> p.Parameters
ans = 
{
  [1,1] = a
  [1,2] = b
}


If Matlab Results has the same order of values as the order of add*, then
that's an implementation detail. And an undocumented one. Since Results is a
struct, the type of thing where order of keys does not usually matter, what is
the use case for this?

Also, is this a Matlab compatibility issue? There are more functions in Octave
that return structs where the order of keys differ from Matlab.

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?49389>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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