function
words
words(n) -> words
Allocates a raw buffer of n 32-bit words and returns a words value you can index with buffer[i] to read or write each word as an int. Use it when you want a flat, fixed-size numeric scratch array — a lookup table, a small ring buffer, or per-slot counters — without declaring a model. It is lower-level than a growable []int slice: the size is chosen up front and there is no push. For byte-granular storage use bytes instead.
Parameters
nthe number of 32-bit words to allocateExample
program WordScratch {
handler SumScores phase Start {
let scores = words(3)
scores[0] = 10
scores[1] = 20
scores[2] = 30
var total: int = 0
for index in 0 .. 3 {
total = total + scores[index]
}
print(total)
}
}