While implementing macros for Simplex, I noticed that the List<T, N> type can hold strictly fewer elements than its specified size bound.
For example, if we declare a list with a size limit of 16, it can only hold a maximum of 15 elements.
https://docs.simplicity-lang.org/simplicityhl-reference/type/
|
"There must be fewer list elements than the bound {bound}" |
|
Partition::Parent { slice, bound } => slice.len() + 1 == bound.get(), |
I'm curious about the technical reasoning behind this design choice. Are you inserting the head of the list as the 0th element, resulting in the truncated capacity?
Or a binary tree uses a recursive cutoff, by using 2^i elements in each leaf?
Or is this purely related to how lists are encoded for contract stack execution?
From a developer's perspective, it feels counterintuitive that a list bound of N forces an "off-by-one" capacity limit.
While implementing macros for Simplex, I noticed that the List<T, N> type can hold strictly fewer elements than its specified size bound.
For example, if we declare a list with a size limit of 16, it can only hold a maximum of 15 elements.
https://docs.simplicity-lang.org/simplicityhl-reference/type/
SimplicityHL/src/value.rs
Line 955 in aeeb37e
SimplicityHL/src/array.rs
Line 179 in aeeb37e
I'm curious about the technical reasoning behind this design choice. Are you inserting the head of the list as the 0th element, resulting in the truncated capacity?
Or a binary tree uses a recursive cutoff, by using 2^i elements in each leaf?
Or is this purely related to how lists are encoded for contract stack execution?
From a developer's perspective, it feels counterintuitive that a list bound of N forces an "off-by-one" capacity limit.