octave-maintainers
[Top][All Lists]
Advanced

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

user function return values


From: John W. Eaton
Subject: user function return values
Date: Tue, 15 Sep 2009 11:51:58 -0400

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?

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?

Thanks,

jwe


reply via email to

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