Andreas Rossberg (2013-09-05T10:42:41.000Z)
On 5 September 2013 12:24, Niko Matsakis <niko at alum.mit.edu> wrote:
> On Thu, Sep 05, 2013 at 09:15:11AM +0200, Andreas Rossberg wrote:
>> Maybe it actually _is_ worth considering a different equality
>> semantics for structs and typed arrays. In essence, they are a kind of
>> super-fat pointer, and we could give them the usual notion of (fat)
>> pointer equality. That is, two objects are equal if they are
>> equivalent views to the same backing store. It would make them value
>> types, more or less.
>>
>> As an implementor, I don't like this idea too much :), but from a user
>> perspective it would probably be saner.
>
> Perhaps. Note that arrays can still point at overlapping memory
> without being *equal*. So the same basic guarantees hold as today:
>
>   `==` => aliasing
>   `!=` => nothing in particular

Yes, sure. The same holds for plain pointer equality in C, though
(thanks to primitive types of different size, unions, array semantics,
and other stuff). Pointer comparison is not for detecting aliasing,
unless you know what you are doing.

/Andreas
domenic at domenicdenicola.com (2013-09-09T01:44:52.475Z)
On 5 September 2013 12:24, Niko Matsakis <niko at alum.mit.edu> wrote:
> Perhaps. Note that arrays can still point at overlapping memory
> without being *equal*. So the same basic guarantees hold as today:
>
>   `==` => aliasing
>   `!=` => nothing in particular

Yes, sure. The same holds for plain pointer equality in C, though
(thanks to primitive types of different size, unions, array semantics,
and other stuff). Pointer comparison is not for detecting aliasing,
unless you know what you are doing.