Modules
Each .zp file can contribute declarations to a module. Declarations are
private unless they start with pub.
Public declarations
Section titled “Public declarations”pub record Point { x: Int, y: Int,}
pub fun distanceSquared(point: Point) Int { return point.x * point.x + point.y * point.y;}
fun internalHelper() Int { return 0;}Other modules can access Point and distanceSquared, but not
internalHelper.
Directory modules
Section titled “Directory modules”A directory can contain several .zp files that form one module namespace:
drawing/ canvas.zp color.zp shape.zpA caller imports the directory as one module:
import "drawing";Use this structure when one public module has several cohesive implementation files.
Re-exports
Section titled “Re-exports”pub import makes imported declarations part of the current module’s API:
pub import "geometry" { Point, distanceSquared };Re-exports can provide one stable entry point for a module assembled from several files.
Public API design
Section titled “Public API design”Export the declarations callers need and keep implementation details private. Moving private helpers between files should not require changes in importing code.
The syntax for loading and naming modules is covered in Imports.