bugGNU Octave - Bugs: bug #55495, autoload should only work for .oct...

 
 

bug #55495: autoload should only work for .oct files; documentation should also be clear about that

Submitted by:  Klaus Braun <kmb721>
Submitted on:  Wed 16 Jan 2019 10:38:02 PM UTC  
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Missed Error or Warning
Status:  None Assigned to:  None
Originator Name:  Klaus Braun Open/Closed:  Open
Release:  dev Operating System:  Any

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

( Jump to the original submission)

Mon 21 Jan 2019 08:29:22 PM UTC, comment #6:

Thanks Kai, classdef classes is a interesting new thing to me.

Klaus Braun <kmb721>
Sun 20 Jan 2019 10:28:52 PM UTC, comment #5:

Regarding comment #4, maybe we are going a bit off topic here by discussing your original problem and should move this to the help mailing list if you want more thoughts on it. But did you consider classdef files with static functions? https://octave.org/doc/v4.4.1/Methods.html

Kai Torben Ohlhus <siko1056>
Project Member
Sat 19 Jan 2019 01:10:32 AM UTC, comment #4:

Thank you John.
I understand how function files and script files work (at current implementation).
I was just playing around and searching for a solution for what I want to do. I want to write a single file with several functions (all callable from outside) for e.g. dealing with a peripheral device.
- one function which opens a connection to the device and does some initialization
- one function for writing to the device
- one function for reading from the device
- maybe some other functions
- one function to close the connection

With a function file I can see only one function - no solution.
With a script file I must call at first the script file (to load all the functions) and then I can call the initialization function.
I wanted to save this double initialization procedure.
When I put the initialization code at the beginning of the script (outside a function) then I can not pass any parameters and can get no return value (or can I?).
Then I had the idea to use a function file with the initialization function as the callable function. And in this initialization function I tried to use autoload to load (make callable) the other functions. (And the close function could unload the functions.) Therefore it would be nice when autoload would work for .m files.
While testing this I discovered the strange behaviour of this (original) issue.

Klaus Braun <kmb721>
Thu 17 Jan 2019 10:51:09 PM UTC, comment #3:

In your .m file, f_2 is a subfunction that is only supposed to be visible to the main function defined in that file, f_test. That's why it is not defined after you simply call f_test.

It does appear that autoload can (sort of) work for .m files that contain multiple functions. But given the way that subfunctions work, and because executing a script file that contains multiple functions will define all of them and make them globally visible, I think it would be best if we made autoload work only for .oct files.

John W. Eaton <jwe>
Project Administrator
Thu 17 Jan 2019 10:30:20 PM UTC, comment #2:

Ok, if autoload is only for .oct files and not for ordinary .m function files, then it schould better not be documented in chapter 11.9.5 Functions and Skrips / Function Files, but rather in chapter A.1 Oct-Files.
But I'm wondering why it is working at the 2nd call...

Klaus Braun <kmb721>
Thu 17 Jan 2019 04:13:50 AM UTC, comment #1:

The autoload function is for loading multiple functions from a single .oct file. It does not work for .m files. Multiple functions defined in .m files work differently and should not be affected by autoload. I guess we may need better documentation and possibly an error if the file name given to autoload doesn't name a .oct file.

John W. Eaton <jwe>
Project Administrator
Wed 16 Jan 2019 10:38:02 PM UTC, original submission:

I have a function file 'f_test.m' with 2 functions defined:

The first function executes as expected.
Trying to execute the 2nd function 'f_2' issues an error as expected.
Then I use "autoload('f_2', 'f_test.m')" to load the 2nd function.
When I then call f_2 there is no more error as expected and all seems to be ok, but the function does Nothing.
Only the second (and subsequent) call does execute the code in f_2.

Here is the sequence in the command window:

In my opinion this is a bug - or am I doing something wrong?
To repeat this phenomena you have to close octave and restart it again, or use "autoload('f_2', 'f_test.m', 'remove')" to unload f_2.

Klaus Braun <kmb721>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Digest:
   bug dependencies.

 

Carbon-Copy List
  • -email is unavailable- added by siko1056 (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by kmb721 (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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-01-18 mtmiller CategoryNone => Octave Function
    2019-01-17 siko1056 Dependencies- => bugs #55496 is dependent
    2019-01-17 jwe Item GroupDocumentation => Missed Error or Warning
        Release4.4.1 => dev
        Summaryfunction loaded with autoload does not execute at the first call => autoload should only work for .oct files; documentation should also be clear about that
    2019-01-17 jwe Item GroupIncorrect Result => Documentation

    Back to the top


    Powered by Savane 3.4