3 ms·
> Why can't I just compare these two regions using `A == B` to make sure they are equal? Why is shallow equality useful? You could have `A == B` be true, but
by munificent 4y ago
> Why can't I just compare these two regions using `A == B` to make sure they are equal?
Why is shallow equality useful?
You could have `A == B` be true, but then as soon as you wrap pointers to them in C and D, now `C == D` is false.
- shagie 4y agoIt gets into even more fun if A has a pointer to C has a pointer to B, and B has a pointer to D has a pointer to A.
- codethief 4y ago> > Why can't I just compare these two regions using `A == B` to make sure they are equal? > Why is shallow equality useful? Of course deep equality checks are useful, too, I'm not denying that. But in many cases you are not dealing with several layers of structs nested through pointers. You just want to compare simple structs and be done with it, without having to write an eql() function for every single case. Besides, many other operations in Zig operate directly on the memory, so why should == be any different?