3 ms·
> I think it's more likely the reaction to someone who uses magic languages that perform complicated actions over a simple assignment. If you think of C as a hi
by kbp 10y ago
> I think it's more likely the reaction to someone who uses magic languages that perform complicated actions over a simple assignment. If you think of C as a high-level assembly language whose assignment instruction is converted into a single machine instruction, this type of behavior is not so surprising.
C assignment isn't that simple. Consider this program:
#include <stdio.h>
struct point { int x; int y; };
int main(void) {
struct point p1 = { 0, 0 };
struct point p2 = p1;
++p2.x;
printf("(%d, %d), (%d, %d)\n", p1.x, p1.y, p2.x, p2.y);
}
It prints "(0, 0), (1, 0)", as most people would expect. C isn't as transparent a layer over assembler as some people like to imagine; it just doesn't have first class arrays.
- TillE 10y agoThat's just doing a copy of contiguous memory though? Sure, C has simple custom data types. I like to think of it as one small step above assembly languages; it's certainly not a "portable assembly", but it's about as low as a high-level language can possibly be.
- kbp 10y agoYes, C is definitely a low-level language, I was just responding to someone's inaccurate justification for why you can't copy arrays like that.