bugGNU Octave - Bugs: bug #63023, Private function not available in...

 
 

bug #63023: Private function not available in PKG_ADD context

Submitter:  Maged Rifaat <magedrifaat>
Submitted:  Tue 06 Sep 2022 07:34:31 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  Need Info Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 7.2.0 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 09 Oct 2022 12:40:44 PM UTC, comment #2: 

No reproducer provided in more than a month.
Closing report.

It can be re-opened when some example code that reproduces the issue is provided.

Markus Mützel <mmuetzel>
Group administrator
Wed 07 Sep 2022 07:35:41 AM UTC, comment #1: 

I'm not sure I understand correctly. Could you please attach a minimal reproducer?

From what I gathered, you are trying to do the following:
- You have a (PKG_ADD) script in a folder that has a function in a private folder.
- You create a handle to the private function in that script.
- You'd like to call the private function after the script has executed (from a folder that doesn't have direct access to the `private` folder).

I tried to replicate this with the following in Octave 7.2.0:
- Create a folder `test_dir0` with the following `PKG_ADD` file:

disp('In folder with private function');
priv_fcn = @private_fcn;

priv_fcn()

cd ..  % or any other folder that doesn't have access to private_fcn

disp('In folder away from private function');

priv_fcn()


- In that folder, create a `private` folder.
- In that `private` folder, create the file `private_fcn.m` with the following content:

function private_fcn()

disp('private_fcn');

end

- `cd` to the parent folder of the folder with the `PKG_ADD` script.
- From here, I see the following in Octave:

>> addpath(canonicalize_file_name('test_dir0'))
In folder with private function
private_fcn
In folder away from private function
private_fcn
>> priv_fcn()
private_fcn


That use case seems to work for me...

Markus Mützel <mmuetzel>
Group administrator
Tue 06 Sep 2022 07:34:31 PM UTC, original submission:  

I am not sure if this is a bug or the intended behavior.

Trying to use a private function handle in a PKG_ADD command (or a PKG_ADD script) doesn't work (the function appears to be undefined).

I understand that per the documentation:

Then if the path to func1 is <directory>/func1.m, and if func2 is found in the directory <directory>/private/func2.m, then func2 is only available for use of the functions, like func1, that are found in <directory>.


But apparently PKG_ADD commands in the function file func1 don't have the same access as func1 itself so it can't access func2.

I want to also explain my use-case to further explain why I find this inconvenient. In scripts/image/imformats.m line 67 it is explained that the function handlers for the different image formats can be modified with a call to imformats with "update" as a first parameter and a struct holding the function handlers as a second parameter. It is further encouraged in the next paragraph to use PKG_ADD for this task.

The problem is if I try to use PKG_ADD to set the function handlers to private octave functions, the user won't be able to grab these handlers and use them (but surprisingly the image functions are able to?), so a function handle like `isa` will be completely useless because this is the only way it can be used (i.e. the user have to get its handle to use it).

Maged Rifaat <magedrifaat>

 

(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

Items that depend on this one: None found

 

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

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-10-09 mmuetzel Open/ClosedOpen Closed
    2022-09-07 mmuetzel StatusNone Need Info

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code