Add a New Comment (Rich Markup)
The load-path code probably needs some rethinking, including deciding whether we should be automatically executing code from PKG_ADD and PKG_DEL files (see bug #48880).
I looked very briefly at the load-path.cc code, and there is actually already some code in there breaking the new path argument into a std::set<std::string>, so it may not be that hard to do the same with the current path and get the set differences. This bug is the kind of asymmetry that annoys me, so I may work on it time permitting. If it's not done in time for 6.1, no big deal, been working the same way for many releases now.
I agree with your assessment of the situation. path, rmpath, and addpath are C++ rather than m-files which is a bit sad. If they were merely m-files then we could call setdiff to determine the differences. It is possible to call m-files from C++ using octave::feval, and this still might be the fastest way to get to a solution.
And while we're at it, setting the same path() twice in a row should not source the PKG_ADD of a directory since it was already in the previous load path. In other words, to handle PKG_ADD and PKG_DEL properly, how I think users expect them to work, we need to compute a difference of directories each time a new load path is set, and only call PKG_ADD or PKG_DEL for directories that have been added to the set or removed from the set.
For symmetry, the PKG_DEL file in a directory should be sourced when a directory is removed from the load path as a side effect of calling path(). Here is an example that expresses the problem and the asymmetry:
>> orig_path = path (); >> addpath /tmp/mypath Adding /tmp/mypath to the load path >> with_path = path (); >> rmpath /tmp/mypath Removing /tmp/mypath from the load path >> path (orig_path); >> path (with_path); Adding /tmp/mypath to the load path >> path (orig_path); >> path (orig_path); >> path (with_path); Adding /tmp/mypath to the load path >> path (with_path); Adding /tmp/mypath to the load path >> path (orig_path); >> path (orig_path);
The PKG_ADD and PKG_DEL files (each containing just a disp) are each executed when the user calls addpath() and rmpath() on the directory in question. The PKG_ADD file is also sourced when the user calls path() to set an entire path string and the new path contains /tmp/mypath. However, the PKG_DEL file is not sourced when the user sets a new path() that does not contain /tmp/mypath and the previous path did contain it. I believe path() needs to check for directories removed by assigning a new full load path for full symmetry and reliability of the PKG_ADD and PKG_DEL features.
(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
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 project members can vote.
Please enter the title of George Orwell's famous dystopian book (it's a date):
Follow 2 latest changes.
Copyright © 2023 Free Software Foundation, Inc. Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved. The Levitating, Meditating, Flute-playing Gnu logo is a GNU GPL'ed image provided by the Nevrax Design Team. Source Code
Powered by Savane 3.11