[wishlist] pkg require
Francesco Potorti`
Potorti at isti.cnr.it
Thu Oct 23 12:36:50 CDT 2008
>> Since, at least in 3.0, 'pg load' is so slow, even if the package is
>> already loaded, would it make sense to allow for loading a package if
>> not already loaded?
>>
>> Solution 1: 'pkg load' should only load a package if not already loaded,
>> unless an option -force is given that reloads the package.
>>
>> Solution 2: 'pkg load' accept a -require option which loads the package
>> only if not already loaded.
>>
>> Solution 3: 'pkg require' loads a package only if not already loaded.
>>
>Its not that simple.. "pkg load <package>" doesn't reload a package (ie
>install on the path) if it is already installed. However, what it does
>do is recursive check all of the dependencies of <package> to see if
>they are loaded, and is very careful of the order in which packages are
>placed on the path to handle the case that two packages install a
>function with the same name or that the newly loaded package uses the
>dependent package in its PKG_ADD file..
I see. In my experience, that work takes time. I still propose to add
a way to save that time. From your description, it looks unsafe to do
it by default. So I would retire my proposal #1 above, and keep #2 and
#3, Maybe in #2, the option should be named -nocheck, or -quick rather
than -require.
Just as an example, I personally use this, which speeds things up a lot:
===File ~/math/octavelib/utils/pkgrequire.m=================
function pkgrequire (varargin)
try pkglist = pkg("list");
catch error("This is not Octave 3");
end_try_catch
for i = 1:nargin
pkgname = varargin{i};
found = false;
for p = [pkglist]
if (strcmp (pkgname, p{1}.name))
found = true;
if (!p{1}.loaded)
pkg ("load", pkgname)
endif
break;
endif
endfor
if (!found)
warning ("pkg_not_found", "Package %s not found", pkgname)
endif
endfor
endfunction
============================================================
--
Francesco Potortì (ricercatore) Voice: +39 050 315 3058 (op.2111)
ISTI - Area della ricerca CNR Fax: +39 050 315 2040
via G. Moruzzi 1, I-56124 Pisa Email: Potorti at isti.cnr.it
(entrance 20, 1st floor, room C71) Web: http://fly.isti.cnr.it/
More information about the Bug-octave
mailing list