Package Overview
As the size of a project grows, managing source code within a single large file becomes increasingly difficult. In this case, you can group the source code by functionality, separating code into distinct groups that are managed independently. Each group of code generates its own output file. You can import specific output files for the desired functionalities or combine various functions for more complex features for more efficient project management.
In Cangjie, a package is the minimum unit of compilation. Each package can independently produce output such as AST files, static library files, and dynamic library files. Each package has its own namespace, and top-level definitions or declarations (except for overloaded functions) cannot share the same name within a package. A package can contain multiple source files.
A module is a collection of packages and is the minimum unit of distribution for third-party developers. The program entry of a module must be in its root directory. A module can have at most one main
as the program entry at the top level. The main
either has no parameters or has parameters of the Array<String>
type. The return type can be integer or Unit
.