Mon 10 Apr 2017 02:45:53 PM UTC, comment #8:
I got someone to test those so I pushed the following tests
http://hg.savannah.gnu.org/hgweb/octave/rev/5a3c3ff03167
|
Mon 10 Apr 2017 02:10:30 PM UTC, comment #7:
This error message is just wrong. It looks like a Matlab bug so I don't think we will replicate it:
Can you run one last test, please:
|
Sun 09 Apr 2017 08:31:59 PM UTC, comment #6:
Here the output for the 3 snippets:
|
Sun 09 Apr 2017 04:54:31 PM UTC, comment #5:
Well, Matlab compatibility seems to make it impossible to have
positional options whose value is a parameter key. I pushed this
change which adds those tests and also works for Switch options:
http://hg.savannah.gnu.org/hgweb/octave/rev/f1bf2590272a
Can someone with Matlab tell us how it behaves in the following cases?
+verbatim-+
%% Does this errors about missing value for parameter line?
p = inputParser ();
p.addOptional ('op1', 'val1');
p.addParameter ('line', 'circle');
p.parse ('line');
p.Results ()
-verbatim-
|
Sat 08 Apr 2017 08:33:13 AM UTC, comment #4:
I get this:
|
Fri 07 Apr 2017 06:38:59 PM UTC, comment #3:
Based on the comment for the test, I assumed that Matlab behaved as the test expected. For your example, that would mean setting line to "circle" and op1 and op2 to their default values. Could someone test this in Matlab?
|
Fri 07 Apr 2017 05:53:34 PM UTC, comment #2:
> It seems reasonable to me to stop processing optional parameters as soon as a name/value pair is recognized. Is there some reason not to do that?
The name of a parameter can also be a valid value for a positional option. Since positional options must come first, if a value is a valid positional option, then it should be treated as such instead as key/value pair. Consider this case:
Should op1 and op2 should be set to line and circle respectively, and line be set to the default value of tree? Or should op1 and op2 be set to their default values and line be set to circle?
I think the current behaviour is the most logical since positional options should be all be processed before trying to match key value parameters. But I guess we need to do whatever Matlab does. What does Matlab do?
|
Fri 07 Apr 2017 04:25:52 PM UTC, comment #1:
I checked in the following changeset:
http://hg.savannah.gnu.org/hgweb/octave/rev/7b594fcfa32b
It seems reasonable to me to stop processing optional parameters as soon as a name/value pair is recognized. Is there some reason not to do that?
|
Fri 07 Apr 2017 04:19:09 PM UTC, original submission:
Creating this bug report so that the following test in inputParser.m can have a bug report number:
|