フィルターのクリア

How to find package functions that are shadowed?

6 ビュー (過去 30 日間)
per isakson
per isakson 2021 年 10 月 11 日
編集済み: Pramil 2024 年 5 月 22 日
I'm missing something.
It is possible to have several package functions with identical fully qualified names, e.g. p1.test, on the search path. The statement
which( 'p1.test', '-all' )
should be the way to discover shadowed package functions. However, I fail to make that work. This script below illustrates my problem. which() finds only one of the two p1.test
%%
addpath( cd )
mkdir( cd, '+p1' );
mkdir( fullfile(cd,'f1'), '+p1' );
addpath(fullfile('.','f1'));
str2txt( fullfile(cd,'+p1','test.m'), '% test' );
str2txt( fullfile(cd,'f1','+p1','test.m'), '% test' );
%%
cd ..
which( 'p1.test', '-all' )
/users/mss.system.iBN0QN/f1/+p1/test.m % static method or package function
%%
function str2txt( ffs, str )
fid = fopen( ffs, 'wt' );
fprintf( fid, '%s', str );
fclose( fid );
end

回答 (1 件)

Pramil
Pramil 2024 年 5 月 21 日
編集済み: Pramil 2024 年 5 月 22 日
Hi per,
This is one of the limitations of the “which” function and as of MATLAB R2024a, using the syntax:
which(some.package.fcnName, -all)
This would only give the first path for the package function “fcnName” it finds.
There is a workaround though that you can use instead; which works in both MATLAB R2024a and R2018b:
which -all +some/+package/fcnName
The above will get you all the path of “some.package.fcnName” present on MATLAB’s path.
Hope it helps.

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by