logoalt Hacker News

Index, Count, Offset, Size

65 pointsby ingvelast Wednesday at 8:20 AM17 commentsview on HN

Comments

qoutealltoday at 5:05 AM

With modern IDE and AI there is no need to save letters in identifier (unless too long). It should be "sizeInBytes" instead of "size". It should be "byteOffset" "elementOffset" instead of "offset".

show 3 replies
JSR_FDEDtoday at 7:05 AM

Using the same length of related variable names is definitely a good thing.

Just lining things up neatly helps spot bugs.

It’s the one thing I don’t like about strict formatters, I can no longer use spaces to line things up.

waherntoday at 4:13 AM

Relatedly, a survey of array nomenclature was performed for the ISO C committee when choosing the name of the new countof operator: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3469.htm

It was originally proposed as lengthof, but the results of the public poll and the ambiguity convinced the committee to choose countof, instead.

akdor1154today at 7:00 AM

The 'same length for complementary names' thing is great.

dataflowtoday at 3:48 AM

Is there any other example of "length" meaning "byte length", or is it just Rust just being confusing? I've never seen this elsewhere.

Offset is ordinarily just a difference of two indices. In a container I don't recall seeing it implicitly refer to byte offset.

show 3 replies
card_zerotoday at 3:37 AM

I can't read the starts of any lines, the entire page is offset about 100 pixels to the left. :) Best viewed in Lynx?

zephentoday at 5:00 AM

The invariant of index < count, of course, only works when using Djikstra's half-open indexing standard, which seems to have a few very vocal detractors.

show 1 reply