Difference between revisions of "XCSG:Package"
Line 1: | Line 1: | ||
+ | A package is a [[Namespace]] that is instantiated only once at runtime. 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 | ||
Line 6: | Line 10: | ||
.namespace [27, pp. 10, 132], | .namespace [27, pp. 10, 132], | ||
package [35, p. 24, section 2.7.2] }} | package [35, p. 24, section 2.7.2] }} | ||
− | |||
− | |||
− | |||
− | |||
==Semantics== | ==Semantics== |
Revision as of 16:58, 15 May 2014
A package is a Namespace that is instantiated only once at runtime. 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 [38, p. 119] and C++ [46, p. 177] 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” [46, p. 847]. 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 [44, p. 15].