Queries regarding value classes
Quân Anh Mai
anhmdq at gmail.com
Sun Mar 20 18:08:44 UTC 2022
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