Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That doesn't make any sense. If `i` is a `u8` and `xs` is an array, then `xs[i as usize]` works today.

The criticism isn't even specific to exotic environments. The same reasoning applies at bigger widths too. I've certainly used `u32` in places instead of `usize` to avoid doubling the size of my heap use on 64-bit systems.

Implicit widening would be nice, but it isn't necessary.



In the firmware I mentioned on an 8 bit system using a 16 bit indx increases the resulting code by 2-3X.

A lot of times the code size doesn't matter. In my case it's important. Consider a lowly printf statement in my firmware.

It takes about 120 bytes of code. A trivial amount! Lets see how much that costs us.

Marginal cost of flash is about $1.00/64k. So 120b/64k X $1 = $0.001875 per unit.

We ship 100,000 units per year.

So that printf costs $187 per year.


I feel like you just repeated your previous comment. I don't need a lesson on unit economics. My whole point is that your don't need a 16 bit index.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: