Redundant nargin checking in m-files?

Rik <[email protected]>
Newsgroups gmane.comp.gnu.octave.maintainers
Message-ID <MTAwMDAyNS5ub21hZA.1600373920@quikprotect>
jwe,

I happened to be looking at listfonts.m which starts with

function fonts = listfonts (h)

  if (nargin > 1)
    print_usage ();
  endif

This is an established input validation strategy to first check the number
of arguments, and then look for correct type, and finally check for correct
value.

But when I call listfonts with too many arguments I now get

octave:3> listfonts (1,2)
error: listfonts: function called with too many inputs
error: called from
    listfonts

I remember vaguely that you made a change to the parser/interpreter and
that it now checks for too many inputs.  Does that make all of the input
number checking in m-files redundant at this point?

On the bad side, it will be a lot of work to remove the unnecessary code. 
But on the good side, the code will be streamlined and slightly faster
since the nargin check is happening in compiled code rather than
interpreted code.

--Rik
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.