octave-maintainers
[Top][All Lists]
Advanced

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

Re: function files (was: why is octave such a crap?)


From: PhilipNienhuis
Subject: Re: function files (was: why is octave such a crap?)
Date: Wed, 17 Aug 2016 11:01:58 -0700 (PDT)

Mike Miller-4 wrote
> On Wed, Aug 17, 2016 at 14:50:30 +0000, Frank Zack wrote:
>> function retval=octsux(x)
>>   if(x<1.3)                         % -inf&lt;x&lt;1.3
> &gt;     retval=1/(exp(-x(1))+0.27);
>>   else                                 % 1.3<=x
> <inf
>>
>      retval=4/(3*sqrt(pi))*(x(1)^2+pi^2/6)^(3/4);
>>   endif  
>> endfunction
>> 
>> octsux(10)
>> warning: function name 'octsux' does not agree with function file name
>> '/user/ME/test.m'
>> error: 'x' undefined near line 2 column 6
>> error: called from
> 
> Is the error message unclear? The function name must be the same as the
> name of the .m file. A .m file may contain more than one subfunction,
> but every public function must be in its own .m file with the same name.
> 
> https://www.gnu.org/software/octave/doc/interpreter/Function-Files.html

IMO "crap" is unduly offensive but as far as Matlab compatibility goes the
OP does have a point:

Matlab r2016b prerelease (the version I have at hand here) does accept
function names that are different than the .m file name. 
Matlab informs the user of this at file saving time rather than error'ing
out at execution time.

Matlab seems to use the first function declaration in the file as entry
point for the entire .m file.

Philip




--
View this message in context: 
http://octave.1599824.n4.nabble.com/why-is-octave-such-a-crap-tp4679275p4679294.html
Sent from the Octave - Maintainers mailing list archive at Nabble.com.



reply via email to

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