bartc said:
Interesting. I developed a pretty much parallel language to C in the
1980's.
That /did/ have struct compares, and it seemed work!
However, my structs didn't have 'holes', as I knew nothing about C's method
of automatic padding (I did this manually as needed.)
Even with holes, I can imagine various schemes to compare two structs that
would not require an arbitrarily large amount of code (such as looping
through a bitmap showing the bytes that need to match, or finding out
exactly what the difficulty is in making sure padding bytes are zero) .
Padding bytes (and padding bits, for bit-fields) mightn't
be the only problem. For example:
struct { char c[100]; }
x = { "Hello" }, y = { "Hello" };
x.c[99] = 'x';
y.c[99] = 'y';
assert (strcmp(x.c, y.c) == 0);
assert (x == y); /* ??? */
The structs x,y are "equal" if their c arrays are thought of
as containing strings, "unequal" if they're thought of as
holding a hundred characters each.