[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #42882] Discrepancy between eval()/run() and s
From: |
anonymous |
Subject: |
[Octave-bug-tracker] [bug #42882] Discrepancy between eval()/run() and source() when calling external .m file |
Date: |
Thu, 31 Jul 2014 02:17:03 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.123 Safari/537.36 |
URL:
<http://savannah.gnu.org/bugs/?42882>
Summary: Discrepancy between eval()/run() and source() when
calling external .m file
Project: GNU Octave
Submitted by: None
Submitted on: Thu 31 Jul 2014 02:17:01 AM UTC
Category: Octave Function
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Other
Status: None
Assigned to: None
Originator Name: Jonathan Dodd
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: 3.8.0
Operating System: GNU/Linux
_______________________________________________________
Details:
This report relates to the lack of re-compilation of a .m file when it changes
during the execution of a script. This may be intentional/desirable for
performance reasons. However, it seems to differ from Matlab, causes a
discrepancy between normal execution and execution in debug mode, and should
be made explicit in the documentation.
The context in which I came across this behaviour related to an existing
non-Octave program adapted to output matrices in .m format. A loop in my
Octave script ran this program with different input parameters before calling
the resulting .m file to load the data. I had expected each new data set to be
read from the output file in turn, but in fact only the first data set was
ever used.
Curiously, each new data set was correctly loaded in debug mode. This may be
because Octave checks for changes at each new line when running interactively,
as explained here
<https://www.gnu.org/software/octave/doc/interpreter/Function-Files.html#Function-Files>.
Thus, a changing .m file is not re-compiled when a script is running normally,
but _is_ re-compiled when step-debugging - clearly undesirable.
While the documentation
<https://www.gnu.org/software/octave/doc/interpreter/Function-Files.html#Function-Files>
does cover the re-compilation of changing files, it is not immediately obvious
that files will _not_ be recompiled during the execution of a script - even
with ignore_function_time_stamp("none"). I therefore suggest that this is made
explicit, and it is explained that if .m files change during script execution,
the relevant function should should either be cleared, or the script file run
using source() or run(), which ensure re-compilation.
Finally, in contrast to Octave, Matlab does seem to re-compile functions
during script execution, but only after a time delay of about 1 second.
However, experiments seemed to indicate that this behavior was in fact quite
undesirable, producing different outputs depending on the time at which the
script was executed (NB this was relayed to me on IRC - I am unsure whether it
related to straight calls, calls through run() or both).
= Example =
See attachment. Comment out lines in foo() as appropriate. using run() or
source() will result in y=1, 2, ... , 10. Calling testb directly results in y
= 1, 1, ... , 1. Matlab may produce something like y = 1, 1, 1, 1, 6, 6, 6, 6,
6, 6, depending on the run.
_______________________________________________________
File Attachments:
-------------------------------------------------------
Date: Thu 31 Jul 2014 02:17:01 AM UTC Name: recompiletest.m Size: 274B By:
None
<http://savannah.gnu.org/bugs/download.php?file_id=31803>
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?42882>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #42882] Discrepancy between eval()/run() and source() when calling external .m file,
anonymous <=