Re: Operator overloading for userspace objects

From: Date: Fri, 31 Jan 2020 15:55:28 +0000
Subject: Re: Operator overloading for userspace objects
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-108335@lists.php.net to get a copy of this message
> Also, I want to reiterate: Any of these operations MUST be designed to return a new value, > never modify in place. These operators only make sense on value objects, not service objects, and > value objects should be immutable. I completely agree. This was the gist of my earlier comments. Maybe we should resurrect discussion of the immutable classes and properties RFC: https://wiki.php.net/rfc/immutability If we add the ability to specify immutability, then we can enforce in the engine that the left and right operands must be immutable. For example: public function __add(immutable $left, immutable $right); Cheers, Ben

Attachment: [application/pgp-signature] Message signed with OpenPGP signature.asc
« previous php.internals (#108335) next »