Le 01/07/2021 à 16:38, Nicolas Grekas a écrit :
Hi NIkita,
I voted against the proposal because it doesn't work with cloning at all.
Cloning is a critical feature of stateful objects, and we should solve it
the same version that introduces readonly IMHO.
If we figure out that we can't agree on a sensible improved behavior for
cloning, we're going to be in a dead-end with readonly.
I respectfully disagree.
Having readonly properties and immutable objects is a must have, but
changing property of an object while cloning, not so much. There's many
case where readonly properties will be valuable where you never need to
clone your objects. Actually, cloning objects is not something you do
every day.
Please note that I agree with you that advanced / flexible clone
semantics would be a nice to have, but I don't see the lack of it
blocking for readonly properties.
I personally don't have any real use case where I couldn't implement
withers on my objects doing the same than dedicated advanced clone
semantics. Could you please provide some real world examples ? People
could change their minds if they could see why it's so blocking for you.
Regards,
--
Pierre
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php