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

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

[Octave-bug-tracker] [bug #49793] octave's inputParser only accepts vali


From: John W. Eaton
Subject: [Octave-bug-tracker] [bug #49793] octave's inputParser only accepts validation functions that return true or false
Date: Thu, 8 Dec 2016 15:33:40 +0000 (UTC)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0

Follow-up Comment #6, bug #49793 (project octave):

After thinking about this some more, I agree that the best solution is to do
use nargout to check to see whether the function returns at least one output
and use a try-catch block.  So it would be something like this:


result = true;
try
  if (nargout (val) > 0)
    result = val (in);
  else
    val (in);
  endif
catch
  ## Some kind of error happened in calling the
  ## validation function, so consider it to have failed.
  result = false;
end_try_catch


Even though nargout doesn't work properly for all functions yet, this solution
will work for user-defined validation functions.

We can also make it a priority for the next release to fix Octave so that
nargout will work for built-in functions as well.

    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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