A package is a named collection of related parts; think of a package in the same way as you think of a folder or directory on your local system.
Packages prevent name conflicts by separating files into different contexts. Two parts with the same name cannot be defined in the same package, but two different packages can each have a part with the same name. To prevent conflicts between packages, do not create packages with the same names, even if those packages are in different projects or source folders.
The parts in an EGL source file belong to the same package. The package statement in the file, if any, specifies the name of that package. If you do not specify a package statement, the parts are stored in the root of the source folder and are considered to be in the default package. If you do not specify a package statement, files in the default package cannot be shared by parts in other packages or projects.
Package names are case sensitive. For more information about naming conventions for packages, see the "package" reference topic.
package com.companyb.firstpackage; program testProgram type BasicProgram function main() myVariable myRecordPart; end end Record myRecordPart type BasicRecord field1 int; field2 string; end
package com.companyb.secondpackage; program testProgram2 type BasicProgram function main() myVariable2 com.companyb.firstpackage.myRecordPart; end end
To cause EGL to use the part in the source file, use the import statement. If you import a part in this way, you can use the part as though it were in the current package, without specifying the complete location of the part within its package each time you use it. Importing a part in this way is sometimes called "bringing the part into scope."
package com.companyb.thirdpackage; import com.companyb.firstpackage.myRecordPart; program testProgram3 type BasicProgram function main() myVariable3 myRecordPart; end endNote that the import statement uses the package path to the part and the part name, not the source file name.
For more information about import, see “Writing import and use statements.”