Re:Conflating pointers with arrays: C's biggest mistake? (2009)
by bluecalm on Sunday July 22, 2018 @10:14AM
(#17586848)
I object to reinterpreting bytes of one object as object of another type being C mindset. Yes, this is done sometimes if you really need it (compression being one example) but it's not really something you write everyday in C and doing it to calculate hash is just lazy.
[ Parent
| on HN ]
Re:Conflating pointers with arrays: C's biggest mistake? (2009)
by amluto on Sunday July 22, 2018 @11:41AM
(#17587256)
Except that hashing a block of memory is likely to be much faster than hashing individual fields once there are more than a couple fields.
IMO the right solution would be a special annotation on a struct that says “I want the logical value of this struct to uniquely determine the bytes of the struct’s in-memory representation.”
Of course, adding such an attribute without nasty edge cases may be tricky.