title: “Package” author: “Pierre Laplante laplante@plcb.ca” date: “2023-09-12” version: “1.0.0” section: “1g”
A package is used to group related functions and variables under a common namespace.
Functions inside a package can be called using the syntax:
package_name::function_name();
Variables can also be defined within a package and accessed using the same notation:
package p {
x := 5;
func f() {
"x="; p::x;
}
}
p::f();
p::x;
res={{
package allo {
package error {
}
}
}}.
Output:
.*Parser error, can't use a package error in package allo.
res={{
package p {
func f(i) {
"i="; i;
}
}
p::f(5);
}}.
Output:
res=i=5.
res={{
package p {
func f(i) {
"i="; i;
f(i*2);
}
}
func f(i) {
"i2="; i;
}
p::f(5);
f(6);
}}.
Output:
res=i=5i2=10i2=6.