octave-maintainers
[Top][All Lists]
Advanced

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

Re: Why does Octave ignore additional input arguments ?


From: Julien Bect
Subject: Re: Why does Octave ignore additional input arguments ?
Date: Tue, 09 Feb 2016 11:49:10 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.8.0

Le 09/02/2016 11:29, John W. Eaton a écrit :
On 02/09/2016 04:11 AM, Colin Macdonald wrote:
On 08/02/16 23:56, Julien Bect wrote:
but I find it annoying (and I would be perfectly happy with a default
non-customized error message).

+1 for annoying.

I hadn't paid attention to this problem until recently; *not* looking
forward to doing this everywhere:

if (nargin > ...)
   print_usage ();
endif

I think it would be fairly easy to make exactly that happen automatically.

The question is whether there is some legitimate reason to keep the existing behavior. I'm not convinced that there is, but maybe I'm wrong? It would help me if I see an example of where the current behavior is useful.

I think that essentially two reasons have been invoked to justify keeping the existing behavior :

1) The existing behavior makes it possible to issue customized error message when nargin > nargin_max.

2) In a situation where a package requires its users to provide a handle to a function, say F(x), and then decides to extend the interface with an additional argument, say F(x, y), the existing behavior makes it possible for the package developer to switch to the new interface unconditionally, without requiring the user to modify its own functions.

For the first point there isn't much to say except that, as I said earlier, I would be perfectly happy with a default error message for this. I am not aware of a situation where a customized error message is really needed.

For the second point, Olaf Till had an example involving the optim package. See http://lists.gnu.org/archive/html/help-octave/2009-08/msg00074.html.

Carlo de Falco has proposed a try-catch based solution to Olaf's problem, which I think is fine: http://lists.gnu.org/archive/html/help-octave/2009-08/msg00077.html (especially if the error is accompanied with an error identifier that makes it possible to deal with it cleanly).

But Olaf seemed to think to the try-catch approach wouldn't do: http://lists.gnu.org/archive/html/help-octave/2009-08/msg00078.html.

@++
Julien




reply via email to

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