[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Octave becoming too MATLAB compatible ?
From: |
Tatsuro MATSUOKA |
Subject: |
Re: Octave becoming too MATLAB compatible ? |
Date: |
Sun, 31 Aug 2014 09:03:00 +0900 (JST) |
----- Original Message -----
> From: Julien Bect
> To: octave-maintainers
> Cc:
> Date: 2014/8/30, Sat 15:57
> Subject: Re: Octave becoming too MATLAB compatible ?
>
> Le 29/08/2014 22:21, Ulf Griesmann a écrit :
>> # test script
>> say_hello;
>>
>> function say_hello
>> fprintf('Hello !\n');
>> endfunction
>
> I don't know if it was working before, but I can confirm that I get the same
> result in 3.9.0+ (gui-release branch).
>
> On the other hand, changing the script a little bit:
>
> --------------------
> function say_hello
> fprintf ('Hello !\n');
> endfunction
>
> say_hello;
> --------------------
>
> I get the following output:
>
> --------------------
> warning: function name 'say_hello' does not agree with function file
> name '/home/bect/Sandbox/testscript1.m'
> Hello !
> --------------------
>
> which is weird I think, because the m-file seems to be recongnized as a
> function
> m-file, but still the "say_hello" statement at the end is executed as
> in a script.
>
> Finally, I have also tried to redefine the function inside the script:
>
> --------------------
> disp ("Prevents Octave from thinking it's a function file");
>
> function say_hello
> disp ("Hello !");
> endfunction
>
> say_hello;
>
> function say_hello
> disp ("Helloooo !");
> endfunction
>
> say_hello;
> --------------------
>
> and it gives me:
>
> --------------------
> Prevents Octave from thinking it's a function file
> Hello !
> Helloooo !
> --------------------
>
> It is thus possible to redefine a function inside a script m-file which makes
> my
> opinion rather natural the error that you get it the first example.
>
> I have no idea if all of this is intended or if a bug report must be created.
>
> @++
> Julien
Please read the octave manual carefully.
http://www.gnu.org/software/octave/doc/interpreter/Script-Files.html#Script-Files
The behavior is not a bug.
Tatsuro