bugGNU Octave - Bugs: bug #60493, ignore_function_time_stamp none...

 
 

bug #60493: ignore_function_time_stamp none has no effect

Submitted by:  Tasos Papastylianou <tpapastylianou>
Submitted on:  Sat 01 May 2021 04:29:18 PM UTC  
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  Works For Me Assigned to:  None
Originator Name:  Tasos Papastylianou Open/Closed:  Open
Release:  6.2.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.

 

Mon 03 May 2021 03:31:39 AM UTC, comment #5: 

I separated the single original script in to 4 scripts t1.m, t2.m, t3.m, t4.m.  Try running the sequence by starting Octave and then typing

t1
t2
t3
t4

This works for me and is similar to what Mike was proposing.  Each time Octave returns to the command prompt it has a chance to evaluate whether timestamps have changed.  The sequence works for me.

(file #51366, file #51367, file #51368, file #51369)

Rik <rik5>
Project Administrator
Mon 03 May 2021 03:27:30 AM UTC, comment #4: 

Also, note that the original Stack Overflow example was done on Windows.  Time stamps on that platform can be horrendously crude (for example, everything within 100 milliseconds is tagged with the same timestamp).  That lack of precision is not Octave's fault.  Running interactively helps mitigate this because each change to an m-file is done after the user copy and pastes the new code and then hits return.  This operation typically takes at least 1 second so there is no issue with the imprecise timestamps.

Rik <rik5>
Project Administrator
Sat 01 May 2021 07:46:43 PM UTC, comment #3: 

Sure, I mean that first I paste this into the command window and press Enter

fA = fopen( 'A.m', 'w' ); fprintf( fA, "function A()\n  disp( 'Hello from A' )\n  B()\nend\n" ); fclose( fA );
mkdir private
fB = fopen( 'private/B.m', 'w' ); fprintf( fB, "function B()\n  disp( 'Hello from B' )\n%%  C()\nend\n" ); fclose( fB );
fC = fopen( 'C.m', 'w' ); fprintf( fC, "function C()\n  disp( 'Hello from C' )\nend\n" ); fclose( fC );

fprintf( "-- before activating C within B --\n" )
A()

and I get back

-- before activating C within B --
Hello from A
Hello from B

Now I paste this and press Enter

fprintf( "-- after editing B and activating C within it --\n" )
fB = fopen( 'private/B.m', 'w' ); fprintf( fB, "function B()\n  disp( 'Hello from B' )\n  C()\nend\n" ); fclose( fB );
A()

and I get back

-- after editing B and activating C within it --
Hello from A
Hello from B
Hello from C

And lastly I paste this and press Enter

fprintf( "-- after clearing manually --\n" )
clear functions
A()

and of course I get back

-- after clearing manually --
Hello from A
Hello from B
Hello from C

Mike Miller <mtmiller>
Project Administrator
Sat 01 May 2021 07:15:31 PM UTC, comment #2: 

Hi Mike, thanks for the input!

Would you mind giving an example of what you mean?

The process I mention below (and also the one in the stackoverflow link) do not work as expected even when done manually with calls in the interpreter and edits done manually (i.e. not via fopen). If you edit the function files manually, the outcome is an error about C() being undefined,m as per the description in the stackoverflow link.

Tasos Papastylianou <tpapastylianou>
Sat 01 May 2021 07:10:03 PM UTC, comment #1: 

If my understanding is correct, the logic that checks whether a function is out of date only applies after returning from a script or a function call, to the interactive prompt. In other words, I think the working assumption is that a user would be editing function files, and not self-modifying code.

If you run the example interactively, it works as expected.

So maybe the docs should be updated to emphasize that this feature depends on interactive use.

Mike Miller <mtmiller>
Project Administrator
Sat 01 May 2021 04:29:18 PM UTC, original submission:  

According to the octave manual[0] the command

ignore_function_time_stamp none

will cause octave to "always check time stamps on files to determine whether functions defined in function files need to recompiled".

The intent of this command, as I understand it, is to always check files for modifications, allowing one to modify a function file and use the updated definition within an ongoing session, without having to restart the session, and without having to run "clear functions" first.

However, the command seems to have no effect in practice.

Example (adapted from [1]):

ignore_function_time_stamp none
fA = fopen( 'A.m', 'w' ); fprintf( fA, "function A()\n  disp( 'Hello from A' )\n  B()\nend\n" ); fclose( fA );
mkdir private
fB = fopen( 'private/B.m', 'w' ); fprintf( fB, "function B()\n  disp( 'Hello from B' )\n%%  C()\nend\n" ); fclose( fB );
fC = fopen( 'C.m', 'w' ); fprintf( fC, "function C()\n  disp( 'Hello from C' )\nend\n" ); fclose( fC );

fprintf( "-- before activating C within B --\n" )
A()

fprintf( "-- after editing B and activating C within it --\n" )
fB = fopen( 'private/B.m', 'w' ); fprintf( fB, "function B()\n  disp( 'Hello from B' )\n  C()\nend\n" ); fclose( fB );
A()

fprintf( "-- after clearing manually --\n" )
clear functions
A()

When the above is run as a script, the second step doesn't show the call to C(), even though that instruction is now 'active' (i.e. uncommented) in the file. Futhermore, if the modifications aren't made via 'fopen', but manually in an editor, this results in an explicit error, as detailed in [1].

If my understanding is correct, the role of 'ignore_function_time_stamp none' is to explicitly always check if a function file has been modified and fetch the updated definition before running it, so the above behaviour is not the intended behaviour. (I have no problem with this behaviour from an optimisation point of view, but based on the documentation of that command, this is a bug).

[0] https://octave.org/doc/v6.2.0/Function-Files.html#index-ignore_005ffunction_005ftime_005fstamp
[1] https://stackoverflow.com/questions/67334895/access-private-functions-from-private-functions-in-octave-bug

Tasos Papastylianou <tpapastylianou>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #51366:  t1.m added by rik5 (438B - text/x-matlab)
file #51367:  t2.m added by rik5 (119B - text/x-matlab)
file #51368:  t3.m added by rik5 (68B - text/x-matlab)
file #51369:  t4.m added by rik5 (65B - text/x-matlab)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by tpapastylianou (Submitted the item)
  •  

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

    Only project members can vote.

     

     

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-05-03 rik5 Attached File- => Added t1.m, #51366
        Attached File- => Added t2.m, #51367
        Attached File- => Added t3.m, #51368
        Attached File- => Added t4.m, #51369
        StatusNone => Works For Me

    Back to the top


    Powered by Savane 3.6