octave-maintainers
[Top][All Lists]
Advanced

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

Re: Cannot "run" a function file in dev branch.


From: Rik
Subject: Re: Cannot "run" a function file in dev branch.
Date: Tue, 8 Aug 2017 09:27:37 -0700

On 08/08/2017 09:00 AM, address@hidden wrote:
Subject:
Cannot "run" a function file in dev branch.
From:
siko1056 <address@hidden>
Date:
08/07/2017 12:42 PM
To:
address@hidden
List-Post:
<mailto:address@hidden>
Content-Transfer-Encoding:
7bit
Precedence:
list
MIME-Version:
1.0
Message-ID:
<address@hidden>
Content-Type:
text/plain; charset=us-ascii
Message:
2

Hi,

Today I built HG ID 9f31de57ad36 [1] (which seems not related to the issue,
it must have been some change in the past week) but ever since I cannot run
function files using the "run" or "source" functions. The problem is
reproducible by creating a tiny echo function file:

$ echo -e "function doit() \n disp ('hi') \nendfunction" > doit.m

>From within Octave's GUI execution works fine by pressing the "Run" button
or "F5" and it works in GUI and CLI by typing:

doit
hi

But not when trying something like this:

run ("/workspace/doit.m")
run ("doit.m")
source ("doit.m")
Script files seem not to be affected. There were some changes to the
interpreter, that I do not fully grasp that fast. Any ideas or is there
something under construction for a while? That is why I did not file a bug
report yet.

Thank you for you attention,

Kai

P.S.: Both functions are not part of Octave's BIST and do not occur that
often in Octave's m-files. So regressions might happen unnoticed.

[1] https://hg.savannah.gnu.org/hgweb/octave/rev/9f31de57ad36

The issue here is a misconception of what source and run do.  They execute script files, not invoke functions.  So in the example you gave all that Octave did was parse the file and add the function as a command-line function exactly as if you had typed the script at the Octave prompt.  From what I can tell, this is what Matlab does as well (https://www.mathworks.com/help/matlab/ref/run.html).  Just to be sure, someone could try your script in Matlab and see.

This is a change, however, from what Octave used to do in 4.2.1.  Maybe that should be documented in the NEWS file?

--Rik

reply via email to

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