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: Rik
Subject: [Octave-bug-tracker] [bug #49793] octave's inputParser only accepts validation functions that return true or false
Date: Sat, 15 Apr 2023 10:19:46 -0400 (EDT)

Update of bug #49793 (project octave):

                  Status:                    None => Fixed                  
             Open/Closed:                    Open => Closed                 
           Fixed Release:                    None => 9.1.0 (current default)

    _______________________________________________________

Follow-up Comment #11:

I have a solution for this which bypasses the unimplemented nargout
functionality and does not rely on nested try/catch blocks which are a
performance hit and a likely frequent occurrence given how
validateattributes() works.

Relevant part of the patch is shown below:


      ## Validation function can either produce a true/false result or have
      ## no outputs but throw an error when failing.  Tricky code here
      ## relies on side effect, but calls validation function only once
      ## which is a performance win and may also be necessary if validation
      ## function maintains state.  See bug #49793.
      err = sprintf ('Checked with "%s"', func2str (val));
      ans = true;
      try
        val (in);  # call function with no arguments in case nargout == 0
        ok = ans;  # use side effect of assignment to 'ans' when nargout == 1
      catch exception
        ok = false;
        err = exception.message;
      end_try_catch


I checked the changeset in on the development branch here:
http://hg.savannah.gnu.org/hgweb/octave/rev/5945e1bd73ea.  This will be a part
of Octave 9.1 released in 2024.  Because this is just an m-file change you can
always go to Mercurial version control system, download the m-file, and
replace your local copy of inputParser.m to get the change earlier.

Marking bug as Fixed and closing report.


    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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