#code Region
The default
#code is the default region. If a file has no region markers, it’s entirely #code. You only need to write #code explicitly when other regions follow.
tape
#code
@profile(t1);
import io from "io";
var state: i64 = 0;
pub fn process(val: i64) -> i64 {
state = state + val;
return state;
}What lives in #code
- Import statements
- Module-level variables and constants
- Function declarations
- Struct, enum, and tagged union definitions
- Component declarations
- Type aliases
@tapeblocks and@tape fn(compile-time execution)@tape const(compile-time constants)extern fnand@export pub fndeclarations@linkdirectives- User-defined attributes (
attr)
Relationship to other regions
#code provides the backing logic for the rest of the file:
#viewcomponents can call functions and reference variables defined here#testtests exercise functions declared here
Last modified: