MATLAB: How to test if a function handle belongs to a particular package

functional programmingooppackages

I have a method that accepts a function handle and then needs to branch depending on whether that function is part of +package1 or +package2. While I can think of some hacks involving parsing the function name and/or package's help text and/or output of dir, is there a better or simpler way?
thanks, -n

Best Answer

Probably the simplest would be to parse the output of
functions(yourfunctionhandle)
The file field of that output will contain the full path to the anonymous function, so will contain the package name, if any.