Is simple assignment allowed with structs

Doug Gwyn gwyn at smoke.brl.mil
Fri Apr 19 04:58:48 AEST 1991


In article <1991Apr18.095803.11624 at netcom.COM> avery at netcom.COM (Avery Colter) writes:
>And so the mindless philosopher asks, "Yes, but WHY was it decided that
>simple struct assignment had universal semantics?"

The reasoning is that if you copy all the member values for a structured
object, you have copied the value of the object itself.  Of course there
are situations where this isn't quite the sort of copying that one really
wants, but it is simple, well-defined, and useful.

>I suggest it was for the reason I stated, that the memory offsets are the
>same for all variables of the same type of struct.

No -- while the latter condition happens to be true, I don't see that it
has any particular force as an argument for supporting structure assignment.
("Necessary but not sufficient.")



More information about the Comp.lang.c mailing list