Parameters
1
archetype test_parameter(p : nat, n : string)
2
3
variable r : nat = 0
4
5
entry exec () {
6
r := p + length(n)
7
}
Copied!
if you compile with this command:
1
$ archetype test_parameter.arl --init '(1, "astring")'
Copied!
the previous contract is equivalent to:
1
archetype test_parameter
2
3
variable p : nat = 1
4
variable n : string = "astring"
5
6
variable r : nat = 0
7
8
entry exec () {
9
r := p + length(n)
10
}
Copied!
You can also prefix a parameter with const keyword which generates a constant instead of a variable.
For example:
1
archetype test_parameter_const(const c : nat)
2
3
variable r : nat = 0
4
5
entry exec () {
6
r := c
7
}
Copied!
with
1
$ archetype test_parameter.arl --init '1'
Copied!
is equivalent to:
1
archetype test_parameter_const
2
3
variable r : nat = 0
4
5
entry exec () {
6
r := 1
7
}
8
Copied!
Last modified 7mo ago
Export as PDF
Copy link
Edit on GitHub