Only export what main (or the host) needs.
Goal
Export add; keep helper private.
@external("env", "log")
declare function log(n: i32): void;
@external("env", "logStr")
declare function logStr(s: string): void;
function helper(n: i32): i32 {
return n * 40;
}
export function add(a: i32, b: i32): i32 {
return a + b;
}
export function main(): void {
log(add(12, helper(1) / 40));
}@external("env", "log")
declare function log(n: i32): void;
@external("env", "logStr")
declare function logStr(s: string): void;
export function units(): i32 {
return 12;
}
export function main(): void {
log(units());
}@external("env", "log")
declare function log(n: i32): void;
@external("env", "logStr")
declare function logStr(s: string): void;
function hidden(): i32 {
return 5;
}
export function main(): void {
log(hidden());
}@external("env", "log")
declare function log(n: i32): void;
@external("env", "logStr")
declare function logStr(s: string): void;
export function main(): void {
log(8);
}