Summary
Currently, static initialisers work well for one-dimensional data (both in terms of inputs and outputs). However, they exhibit perhaps unexpected behaviour for multi-dimensional arrays. At this stage, its not completely clear to me what the right behaviour is.
Example 1 --- Multidimensional Input
static table(address:u16, flag:u1) -> (word:u8) {
0x1, 0x2, 0x3, 0x4
}
pub output out(address:u16) -> (word:u8)
// copy input to output
fn main() {
out[0] = table[0,0]
out[1] = table[0,1]
out[2] = table[1,0]
out[3] = table[1,1]
return
}
This generates the output:
This feels a little odd to me as, normally, arrays accesses bind with the most significant dimension first (e.g. in arr[x][y] is most significant).
Example 2 --- Multidimensional output
Likewise, the following cannot be made to compile for any replacement of ... other than the empty initialiser:
static table(address:u4, flag:u1) -> (left:u8, right:u4) {
...
}
Summary
Currently, static initialisers work well for one-dimensional data (both in terms of inputs and outputs). However, they exhibit perhaps unexpected behaviour for multi-dimensional arrays. At this stage, its not completely clear to me what the right behaviour is.
Example 1 --- Multidimensional Input
This generates the output:
This feels a little odd to me as, normally, arrays accesses bind with the most significant dimension first (e.g. in
arr[x][y]is most significant).Example 2 --- Multidimensional output
Likewise, the following cannot be made to compile for any replacement of
...other than the empty initialiser: