Queries regarding value classes
Julian Waters
tanksherman27 at gmail.com
Mon Mar 21 06:32:00 UTC 2022
I see, it seems like my preconceived views were mistaken, but I think I
finally understand the semantics of value classes. Still, I think parts of
the original discussion might still be an interesting idea worth looking
into later on.
best regards,
Julian
On Mon, Mar 21, 2022 at 2:08 AM Quân Anh Mai <anhmdq at gmail.com> wrote:
> I don't really understand your confusion now.
>
> > a = b would set a to a copy of b rather than make both a and b the same
> object, unlike with regular objects
>
> Where did you get this impression from? Why do you expect value objects to
> be different from identity objects with regards to this aspect? The
> semantics of the assignment operator has nothing to do with the unique
> identities of the objects, there is no reason for them to be different. If
> you want a copy, you make a copy constructor and call it, why do you expect
> an assignment to do a copy after all?
>
> > So far I haven't been able to find anything in the draft talking about
> this
>
> Of course you can't find that part, why do you expect the JEP to contain
> something that is not different and not new in comparison with regular
> objects at the moment?
>
> > since my initial thought was that they were meant to be represented
> directly at their location in memory
>
> You have mistaken the causes and the consequences again, the way the
> objects are represented should comply with the language semantics, not the
> other way around. While this is a factor, it cannot be used as the sole
> reason to decide the permitted behaviours of value objects. And the
> semantics has been decided logically since the opposite would lead to
> illogical behaviours as I said from the beginning.
>
> Regards,
> Quan Anh
>
More information about the valhalla-dev
mailing list