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: siko1056
Subject: Re: Cannot "run" a function file in dev branch.
Date: Tue, 8 Aug 2017 11:00:10 -0700 (PDT)

Mike Miller-4 wrote
> On Tue, Aug 08, 2017 at 09:27:37 -0700, Rik wrote:
>> 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.
> 
> I don't have Matlab, and I can't find a reference at the moment, but I
> think this was an intention change in the 4.2 release, probably for
> compatibility.
> 
> Take a look at the discussion in https://savannah.gnu.org/bugs/?33411,
> in particular comments #2 and #8.
> 
> This intentional change was subsequently lost in
> https://hg.savannah.gnu.org/hgweb/octave/rev/3bb0a937c071, where the
> source_file function no longer looks for functions from what I can tell.
> 
> -- 
> mike

Rik and Mike you are right. The ´run´ command is documented for script files
only, even for Matlab [1,2]. Since I worked with both I (miss)used it for
calling setup scripts and functions (which are initially not on the load
path), the latter without arguments. It was convenient and still works in
Matlab R2017a (even though [2] says the opposite) and I noticed it by
running my own test suite yesterday that "nothing" happened anymore. I don't
think it's worth to be compatible to an undocumented Matlab (bug/feature?).
To get around this I use from now on:

>> old_dir = cd ('/workspace'); doit (); cd (old_dir);

instead of `run ("/workspace/doit.m");`.

Thank you for your help,

Kai

[1]: https://www.gnu.org/software/octave/doc/interpreter/XREFrun
[2]: https://www.mathworks.com/help/matlab/ref/run.html



--
View this message in context: 
http://octave.1599824.n4.nabble.com/Cannot-run-a-function-file-in-dev-branch-tp4684371p4684375.html
Sent from the Octave - Maintainers mailing list archive at Nabble.com.



reply via email to

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