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

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

[Octave-bug-tracker] [bug #57830] rmdir and other file functions should


From: Rik
Subject: [Octave-bug-tracker] [bug #57830] rmdir and other file functions should not return status unless nargout > 1
Date: Wed, 19 Feb 2020 11:15:26 -0500 (EST)
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko

Follow-up Comment #12, bug #57830 (project octave):

@Guillaume: Yes, I see the same thing.  We're dealing with an unfortunate
choice by Matlab.  In UNIX environments, the return value from a function call
is most often an "int" where a value of 0 indicates success, and any non-zero
value indicates failure.

First, Matlab chose to reverse this convention so that a return value of 1
indicates success and a value of 0 indicates failure.  For compatibility, this
means Octave becomes more confusing because Matlab-compatible functions have
to use this convention, but Octave extensions such as the 'stat' function
follow the C library convention and return 0 on success.

Second, Matlab chose to change the type of the status output from int to
logical.  This is a shame because it allows only one binary bit of information
to be communicated.  If an 'int' were used you could encode information in the
return value.  For example, values greater than 1 might indicate a failure,
but not a severe one, more like a warning.  Values less than 1 could indicate
true failure, and 0 would mean success.  In any case, none of that is possible
for functions which must follow Matlab exactly.

As an aside, I find Matlab documentation hard to understand sometimes.  For
'mkdir', they say that the return value on success is 1.  It is only if you
read closely do you find that the data type is logical.  It would have been
much more straightforward if they simply said, the return value was true on
success and false on failure.

I don't have any objections to making the return data type in Octave also a
logical value.  However, could you file a separate bug report about any
instances you find?

    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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