Packages
Every Cangjie program consists of packages. Packages are the basic unit of compilation. Each package has its own namespace and can contain multiple source files.
Program execution starts from the main function. Cangjie's main function doesn't require the func keyword, making it more concise than other languages. The main function can have no parameters or accept command-line arguments of type Array<String>; the return type can be Unit (no return value) or an integer type (such as Int64, representing an exit code).
The package declaration must be on the first non-empty, non-comment line of the source file. If the source file is located in the project's source root directory (default is src), the package declaration can be omitted, and the compiler will use the default package name default. The example code on the right is in the root directory, so the package declaration is omitted.
0 indicates normal program exit, while a non-zero value indicates abnormal exit. This is consistent with Unix/Linux conventions.Click Run to execute the program. Try changing the return value to 1 and observe the change in exit code.