[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #64113] optimget should accept [] as first arg
From: |
Rik |
Subject: |
[Octave-bug-tracker] [bug #64113] optimget should accept [] as first argument |
Date: |
Wed, 26 Apr 2023 14:08:15 -0400 (EDT) |
Follow-up Comment #6, bug #64113 (project octave):
I think we should choose the path that makes sense here, rather than slavish
Matlab compatibility. Testing with R2023a
optimget ([], 'Display')
ans = []
optimget ([], 'Display', 'abc')
ans = 'abc'
optimget (struct, 'Display', 'abc')
=> Unrecognized field name "Display"
Seems inconsistent to accept empty matrix inputs and return the default value,
but not accept empty struct inputs and return the default value.
Also, what is the use case for this? More code---to handle weird
exceptions---means more maintenance burden.
Octave seems better to me because it checks the first argument for being the
expected type (struct) and for the third example, it returns "abc" because
Octave correctly finds that there is no field "Display" in the empty struct.
If anything, I think the input validation could be made more precise. The
code in optimget.m is
if (nargin < 2 || ! isstruct (options) || ! ischar (optname))
print_usage ();
endif
I would use print_usage () only for the case where the number of arguments is
wrong. I would then break out the argument 1 and argument 2 checking to
produce specific error messages about what is wrong with each input.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?64113>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #64113] optimget should accept [] as first argument, Muhali, 2023/04/26
- [Octave-bug-tracker] [bug #64113] optimget should accept [] as first argument, Pantxo Diribarne, 2023/04/26
- [Octave-bug-tracker] [bug #64113] optimget should accept [] as first argument, Muhali, 2023/04/26
- [Octave-bug-tracker] [bug #64113] optimget should accept [] as first argument, John W. Eaton, 2023/04/26
- [Octave-bug-tracker] [bug #64113] optimget should accept [] as first argument, Muhali, 2023/04/26
- [Octave-bug-tracker] [bug #64113] optimget should accept [] as first argument, Nicholas Jankowski, 2023/04/26
- [Octave-bug-tracker] [bug #64113] optimget should accept [] as first argument,
Rik <=
- [Octave-bug-tracker] [bug #64113] optimget should accept [] as first argument, Rik, 2023/04/26
- [Octave-bug-tracker] [bug #64113] optimget should accept [] as first argument, Nicholas Jankowski, 2023/04/26
- [Octave-bug-tracker] [bug #64113] optimget should accept [] as first argument, Rik, 2023/04/27
- [Octave-bug-tracker] [bug #64113] optimget should accept [] as first argument, Nicholas Jankowski, 2023/04/27