octave-maintainers
[Top][All Lists]
Advanced

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

Re: user function return values


From: Jaroslav Hajek
Subject: Re: user function return values
Date: Tue, 15 Sep 2009 21:22:58 +0200

On Tue, Sep 15, 2009 at 5:51 PM, John W. Eaton <address@hidden> wrote:
> On 15-Sep-2009, Jaroslav Hajek wrote:
>
> | Today I discovered that user functions called via feval would always
> | return an octave_value_list of length equal to the number of declared
> | parameters, padded by undefined values for undefined outputs. I'm not
> | 100% sure this was a bug, but I found it very surprising and quite
> | unexpected for extern apps embedding octave; for instance, I was
> | getting surprising bugs in pytave for very simple and correct calls.
> | So I took the liberty to change it:
> | http://hg.savannah.gnu.org/hgweb/octave/rev/080e11f1b0c1
> |
> | If nargout is >= 1, return first nargout values from the output list,
> | incl. undefined values.
> | If nargout == 0, return the 1st value from the list if it is defined,
> | otherwise return 0.
> |
> | The main point is to prevent undefined values being returned in the
> | list, unless the function actually didn't define the requested number
> | of output values.
> |
> | make check passes for me, but chances still are that this may break
> | something, so if you see a gotcha, please let me know.
>
> Did this problem only show up if using feval from C++, or could it
> also be seen from interpreted code?  If the latter, then can you give
> an example?
>

I don't think so. I think the code handling assignment copes up with
the excess variables.
At least I couldn't figure out a way to demonstrate this.

> Do you intend to use the test_feval function in a test?  If so, then I
> think it shoudl be renamed __test_feval__ or something.  Otherwise, if
> it was just for debugging, maybe it should be removed?
>

Oops. Sorry, that was a debugging hack. I removed it.
But doing a test sounds like a good idea, only I'm not sure creating a
built-in function for each test is OK.
Maybe there could be a special DLD function doing some basic tests for
the C++ interface?

-- 
RNDr. Jaroslav Hajek
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz



reply via email to

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