Are namespaces packages?
13 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
David Young
il 22 Gen 2025
Commentato: David Young
il 22 Gen 2025
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 Commenti
Risposta accettata
Steven Lord
il 22 Gen 2025
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.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Source Control in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!