Hypothetically, imagine you swapped in iunk for int, with the unk suffix implying unknown width. Then you put in imem or ireg or isize with the current architecture dependent int meaning.
I have a hard time imagining the HLL folks saying âIâd like to use the iunk type, pleaseâ. I know this isnât what you asked them, but in some sense it is what the compiler is asking them. It feels to me like one of the important experiences with Rust is the compiler saying âletâs be clear, nowâ. Writing code that just runs and does a thing but who really knows what it does cause lol ints ⌠it just feels like a non-goal of Rust. Caveat: Iâm not in charge of Rust goals, nor things that might sink adoption.
If you make the hypothetical change above and then (hypothetically, still) cleaned up rustc and such to use these new types, it seems like youâd get a much clearer picture of where iunk is important, versus where folks want the more meaningful isize sort of type. That sounds like a lot of work, but even if one sticks with int, it would (probably?) make sense to have more specific identifiers like isize for clearer semantic reasons. It would then be a goal to have as few iunks as possible, for portable code. My sense is that most remaining uses of int/iunk would be âgeez, I donât really know how big this could beâŚâ rather than âthis should be machine sizedâ.
The question about having data structures be polymorphic with respect to int sizes is great. I think the right thing is to make people acknowledge that the widths may vary, and have them use isize. It is basically the same as now, I think, except that it is clearer that the type is not âjust any old intâ. It isnât shameful or anything, just a lot clearer. Having both int and isize would mean there is an awkward transition between using the more shameful âiâm not sure what width is aboutâ int and the less shameful âah, got it nowâ isize.