Difference between revisions of "XCSG:Package"
(→Specification: switching to node template) |
|||
(10 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
+ | A package is a [[Namespace]] used simply for organizing code and limiting access, one that is not also a [[Type]], such as a [[Classifier]]. Examples of [[Packages]] in programming languages are packages in Java and namespaces in C++. | ||
+ | |||
+ | Note that, while packages can be nested within other packages in many languages, that nesting typically has no meaning at runtime. For example, in Java, default access (package [[visibility]]) does not grant access to sub-packages or super-packages. Therefore, package nesting is not reflected by the [[Contains]] hierarchy, which might otherwise imply elements are members of a package which are not. | ||
+ | |||
== Specification == | == Specification == | ||
{{Node | {{Node | ||
− | | extends = Namespace | + | | extends = Namespace |
− | | description = A | + | | description = A simple [[Namespace]], grouping related software elements. |
− | + | }} | |
− | + | ||
− | package | + | ==Semantics== |
+ | The semantics of packages are those common to the UML concept of Package, the MS-IL concept of Namespace, the JVM concept of package, and that of namespaces in C++. | ||
+ | |||
+ | ==Language mappings== | ||
+ | Packages are used to represent C++ namespaces and Java packages. | ||
+ | |||
+ | Unnamed packages in Java and C++ can be represented in the obvious way, as Packages with a zero-length name. In Atlas, Java's default package is represented as a package named "default", which is safe from name collisions since "default" is not a valid Java identifier. | ||
+ | |||
+ | In C++ the global scope is just another namespace. As a result we can model it as a package, e.g. with name=”Global”. Features associated with this package represent functions and data members with File scope. |
Latest revision as of 15:09, 26 October 2015
A package is a Namespace used simply for organizing code and limiting access, one that is not also a Type, such as a Classifier. Examples of Packages in programming languages are packages in Java and namespaces in C++.
Note that, while packages can be nested within other packages in many languages, that nesting typically has no meaning at runtime. For example, in Java, default access (package visibility) does not grant access to sub-packages or super-packages. Therefore, package nesting is not reflected by the Contains hierarchy, which might otherwise imply elements are members of a package which are not.
Specification
Metaclass | Package |
---|---|
Extends | Namespace |
Description | A simple Namespace, grouping related software elements. |
All Superkinds | Namespace, Node, ModelElement |
---|
Specified Out Edges | |||
---|---|---|---|
Out Edge | Successor | Multiplicity | Description |
HasVariable | ProgramVariable | ✱ | Links a Classifier or Package to one of its Variables. |
Known Possible In Edges
| ||||
---|---|---|---|---|
Inherited From | In Edge | Predecessor | Multiplicity | Description |
Node | Contains | Node | 1 | Indicates that the predecessor contains the successor in a sense specified by the specific type of Contains edge. |
Known Possible Out Edges
| ||||
---|---|---|---|---|
Inherited From | Out Edge | Successor | Multiplicity | Description |
Namespace | HasVariable | Variable | ✱ | Links a Classifier or Package to one of its Variables. |
Node | Contains | Node | ✱ | Indicates that the predecessor contains the successor in a sense specified by the specific type of Contains edge. |
Semantics
The semantics of packages are those common to the UML concept of Package, the MS-IL concept of Namespace, the JVM concept of package, and that of namespaces in C++.
Language mappings
Packages are used to represent C++ namespaces and Java packages.
Unnamed packages in Java and C++ can be represented in the obvious way, as Packages with a zero-length name. In Atlas, Java's default package is represented as a package named "default", which is safe from name collisions since "default" is not a valid Java identifier.
In C++ the global scope is just another namespace. As a result we can model it as a package, e.g. with name=”Global”. Features associated with this package represent functions and data members with File scope.