Are namespaces packages?
7 ビュー (過去 30 日間)
古いコメントを表示
The R2024a release notes say "The MATLAB language feature known as a package is now called a namespace."
The R2024b release notes say "A package is a collection of MATLAB code, related files, and a package definition file that defines the package identity and dependencies."
So I wanted to check: is the package referred to in the R2024b notes a new kind of thing, different to a namespace, or is the terminology change from R2024a being ignored?
0 件のコメント
採用された回答
Steven Lord
2025 年 1 月 22 日
It is a new thing.
namespaces
The + directory hierarchy that used to be called packages are now called namespaces, so using an example from the unit testing framework the TestCase class (matlab.unittest.TestCase Class) is in the unittest namespace inside the matlab namespace. But TestCase is not part of any package. See this documentation page for more information about namespaces.
packages
A package, going foward, is as you (and the documentation) said: it's a collection of (hopefully thematically related) software files that also lists what it depends upon (and can be depended upon in turn by other packages.) So you could have a collection of functions related to astronomical calculations in an Astronomy package, but in order to use that you need to have a Physics package installed. So the Astronomy package would declare a dependency on the Physics package, meaning when you install Astronomy it would check if Physics is installed and install it if it is not.
The package could contain functions that are not in any namespace (like sin, plot, etc.), functions inside a namespace included as part of the package (like the Physics package could include a function computeGravitationalForce to compute the force of gravity between two objects given their masses and distance apart), or both.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Gravitation, Cosmology & Astrophysics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!