bugGNU Octave - Bugs: bug #42882, Discrepancy between eval()/run()...

 
 

bug #42882: Discrepancy between eval()/run() and source() when calling external .m file

Submitted by:  None
Submitted on:  Thu 31 Jul 2014 02:17:01 AM UTC  
 
Category: Octave FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Other
Status: DuplicateAssigned to: None
Originator Name: Jonathan DoddOriginator Email: -unavailable-
Open/Closed: ClosedRelease: 3.8.0
Operating System: GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Thu 31 Jul 2014 01:20:10 PM UTC, comment #3:

Closing as a duplicate of bug #42883 as suggested in comment #1.

Mike Miller <mtmiller>
Project Administrator
Thu 31 Jul 2014 02:36:13 AM UTC, comment #2:

Resubmitted here.

Jonathan Dodd <gnathan87>
Thu 31 Jul 2014 02:24:59 AM UTC, comment #1:

Oops, very sorry - ignore this report, I forgot to edit the title once I had finished composing the main bit. I will resubmit with a better title.

Jonathan Dodd <gnathan87>
Thu 31 Jul 2014 02:17:01 AM UTC, original submission:

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. 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 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.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #31803:  recompiletest.m added by None (274B - text/x-objcsrc)

 

Digest:
   bug dependencies.

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by mtmiller (Posted a comment)
  • -unavailable- added by gnathan87 (Posted a comment)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 31 Jul 2014 01:20:10 PM UTCmtmillerStatusNone=>Duplicate
      Open/ClosedOpen=>Closed
      Dependencies-=>Depends on bugs #42883
    Thu 31 Jul 2014 02:17:01 AM UTCNoneAttached File-=>Added recompiletest.m, #31803

    Back to the top


    Powered by Savane 3.1-cleanup1