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

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

[Octave-bug-tracker] [bug #62418] inputParser fails because of function


From: Markus Mützel
Subject: [Octave-bug-tracker] [bug #62418] inputParser fails because of function not returning argument
Date: Thu, 5 May 2022 13:49:50 -0400 (EDT)

Update of bug #62418 (project octave):

                  Status:                    None => Wont Fix               
             Open/Closed:                    Open => Closed                 

    _______________________________________________________

Follow-up Comment #1:

This was changed for compatibility with Matlab. It also fails there:

>> {pack()}
Error using pack
Too many output arguments. 


The equivalent in Octave 7.1.0:

>> {pack()}
error: pack: function called with too many outputs
error: called from
    pack


See also this note in the NEWS file for Octave 7:
https://hg.savannah.gnu.org/hgweb/octave/file/302faf5bc425/etc/NEWS.7.md#l38
> - Calling a user-defined function with too many inputs or outputs is now
> an error.  The interpreter makes this check automatically.  If a
> function uses varargin then the check is skipped for function inputs,
> and if a function uses varargout then the check is skipped for function
> outputs.  Input validation for functions typically begins with checking
> that the number of inputs and outputs match expectations.  Existing code
> can be simplified by removing these checks which are now done by the
> interpreter.  Typically, code blocks like the following can simply be
> deleted.
> 
>         ## Checking number of inputs
>         if (nargin > 2)
>           print_usage ();
>         endif
> 
>         ## Checking number of outputs
>         if (nargout > 1)
>           print_usage ();
>         endif

Like described in the NEWS file, one way to adapt your code would be to define
the function in the function handle `v` with `varargout`.

Overall, this is an expected change in behavior between Octave 6 (and earlier)
and 7 (and later).

Closing as won't fix.


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?62418>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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