In order to avoid namespace bloating, I use packages. For example, let Foo
be a function in a package called FooPackage
function Foo()
disp('Foo');
end
I want to use this function in another function called Bar
.
function Bar()
InFunc1();
InFunc2();
InFunc3();
end
this function calls sub-functions. The Naive way is to say explicitly the package name in each call
function InFunc1()
FooPackage.Foo();
end
function InFunc2()
FooPackage.Foo();
end
function InFunc3()
FooPackage.Foo();
end
Alternatively I can use an import in each and every function:
function InFunc1()
import FooPackage.*
Foo();
end
function InFunc2()
import FooPackage.*
Foo();
end
function InFunc3()
import FooPackage.*
Foo();
end
Both of the ways are exhausting. The answer in here says that thes are the only ways. Does anyone has a better suggestion?