On 3/23/12 6:54 PM, Graydon Hoare wrote:
On 12-03-23 06:47 PM, Sebastian Sylvan wrote:
On Fri, Mar 23, 2012 at 1:42 PM, Graydon Hoare<[email protected]> wrote:
- [1,2,3,4,5] -- constant memory, type [int]
- [1,2,3,4,5]/5 -- constant memory, type [int/5]
Hmm, why couldn't literals always be fixed-size? They get
auto-promoted to slices when needed, right? That would remove the need
for the /X part of the literal syntax at least.
Compare:
let x = [1,2,3,4,5]; // x:[int], 5 words storage, 2 words for x
let y = x; // y:[int], 2 words for y
// total: 9 words, 1 array
vs.
let x = [1,2,3,4,5]/5; // x:[int/5], 5 words for x
let y = x; // y:[int/5], 5 words for y
// total: 10 words, 2 arrays
But if literals promoted to slices you could take advantage of that to
achieve the same effect:
let x: [int] = [1,2,3,4,5]; // x:[int], 5 words storage, 2 words for x
let y = x; // y:[int], 2 words for y
// total: 9 words, 1 array
vs.
let x = [1,2,3,4,5]; // x:[int/5], 5 words for x
let y = x; // y:[int/5], 5 words for y
// total: 10 words, 2 arrays
Patrick
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev