Files
mgmt/examples/lang/pool.mcl
James Shubin c937280664 engine: local, lang: core: local: Add a pool function
This adds a new local API for pool allocation, and with it a
corresponding function in the "local" import.
2024-10-04 22:37:39 -04:00

20 lines
516 B
Plaintext

# Remember that across runs if you use --tmp-prefix, this will give you new
# values each time! The local prefix is where the pool of values is taken from!
import "fmt"
import "local"
$ns = "my_namespace"
$i = local.pool($ns, "james") # the uid "james" will always return the same int
$j = local.pool($ns, "purple") # this is like a pool based allocator
print "value:i" {
msg => fmt.printf("i: %d", $i),
Meta:autogroup => false,
}
print "value:j" {
msg => fmt.printf("j: %d", $j),
Meta:autogroup => false,
}