We should not call either of these functions more than once for their values. If we do, it means we have made a mistake with a compiler optimization. This is important, because otherwise if you had code like: $x = random_password() Then this would obviously be a problem. Thankfully, the situations where functions generate unique data is rare, but it's probably something we should take care of.
25 lines
489 B
Plaintext
25 lines
489 B
Plaintext
-- main.mcl --
|
|
import "test"
|
|
# one_instance_a should only produce one value, and will error if initialized twice
|
|
$x = test.one_instance_a()
|
|
test "test1" {
|
|
anotherstr => $x,
|
|
}
|
|
test "test2" {
|
|
anotherstr => $x,
|
|
}
|
|
|
|
# one_instance_b should only produce one value, and will error if initialized twice
|
|
$y = test.one_instance_b()
|
|
test "test3" {
|
|
anotherstr => $y,
|
|
}
|
|
test "test4" {
|
|
anotherstr => $y,
|
|
}
|
|
-- OUTPUT --
|
|
Vertex: test[test1]
|
|
Vertex: test[test2]
|
|
Vertex: test[test3]
|
|
Vertex: test[test4]
|