Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.arch Subject: Re: Optimization by programmers Date: Thu, 01 Oct 2026 07:14:06 -0700 Organization: A noiseless patient Spider Lines: 31 Message-ID: <86h5j5pky9.fsf@linuxsc.com> References: <1177fdi$26ea4$1@dont-email.me> <2026Sep19.082513@mips.complang.tuwien.ac.at> <2026Sep21.191719@mips.complang.tuwien.ac.at> <118tshf$r2kv$1@dont-email.me> <118uv1g$18lk0$1@dont-email.me> <86pky4rpmb.fsf@linuxsc.com> <1193dsi$2pbdi$1@dont-email.me> <868q4qsjdy.fsf@linuxsc.com> <11969ba$3lmsq$5@dont-email.me> <119b6fd$1buj2$1@dont-email.me> <20260927181805.0000132e@yahoo.com> <119bepl$1fl0g$1@dont-email.me> <20260927194301.0000194f@yahoo.com> <86mrt2r33i.fsf@linuxsc.com> <119btc7$1n32h$1@dont-email.me> <86bj9hr91x.fsf@linuxsc.com> <119dne7$2baig$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Thu, 01 Oct 2026 14:14:09 +0000 (UTC) Injection-Info: dont-email.me; logging-data="1275193"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+2IrQgwmxACwQYc1oqG7XyK9BjoDQZZVM="; posting-host="18a74afe15b7c222d977d31c18068e17" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:/4DW9tp0F7hRbfiwqDddyqC8w60= sha1:LJYj2BnLQ6yvs0n6mEBctkwX/Fk= sha256:lUtxLSHjLPwQmewtOfa9EzrcwXm3xK4Oy+/C5JP/P+c= sha1:0tpwNZ8JDxdr3DU6lfYJ4hfCf54= sha256:ylDQWgfATzI3n256MAjWf+wAfERaNsHhdP+HyNoWC2Q= Xref: csiph.com comp.arch:118352 Terje Mathisen writes: > Tim Rentsch wrote: > >> Terje Mathisen writes: >> >>> Tim Rentsch wrote: [...] >>>> I favor a type equivalent to size_t for use as array index variables. >>> >>> In Rust, the only acceptable array index is of type "usize", which is >>> effectively the same as u64 on most platforms these days, but does not >>> need to be so: On a 32-bit target, it would be the same as u32. >>> >>> So effectively very similar to size_t. >> >> Maybe that limitation works okay in Rust. In C sometimes it's >> important to allow a signed value for indexing. Probably 99% of >> the time size_t is good, but not always. > > The fact that array indices are unsigned is one of the more crucial > underpinnings of Rust safety. Even more importantly, all such indices > are verified against the actual array upper boundary. [...] It's nice that array index values are checked against the array bounds. But given that the checks are put in by the compiler, it seems rather silly to insist that index expressions have type usize, especially when a common remedy is just to add a cast. It's like saying the car won't start unless you take off your seatbelt.