This have occurred to me also, I wanted to separate that into two RFC's,
but then how we deal with RFC's that depend on each other?

2016-12-12 1:03 GMT+01:00 Larry Garfield <la...@garfieldtech.com>:

> Assuming this was intended for the list...
>
> On 12/11/2016 05:55 PM, Mathieu Rochette wrote:
>
>> Currently the only "unlocked context" for an object is its
>> constructor.  As discussed previously, that is insufficient.  For any
>> non-trivial object (more than 1-3 internal properties) creating a new
>> one via the constructor only when incrementally building is
>> prohibitively difficult.  The pattern of with*() methods that spawn
>> new objects via clone(), a la PSR-7, needs to be supported.  That is:
>>
>> immutable class Money {
>>    // ...
>>
>>    public function add(Money $other) : Money {
>>      $new = clone($this);
>>      $new->amount += $other->amount;
>>      return $new;
>>    }
>> }
>>
>> I'm not sure how easily we can denote that sort of case.  It's outside
>> the __clone() function itself, which is what makes it difficult.
>> Without that, though, such immutable objects are of only limited use.
>>
>
>
>
>> As you said, it has been already been discussed that a method to build
>> new altered object from an existing one could be improved. Different
>> options were proposed but maybe it's better to start small to get this
>> first part right and add this in another rfc ? having everything at the
>> same time might makes the rfc more difficult to be accepted
>>
>
> On the contrary, an RFC that doesn't fully solve the issue at hand and
> leaves major gaps in place is a poor RFC, and I would expect to be
> justifiably voted down.
>
> --Larry Garfield
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Silvio Marijić
Software Engineer
2e Systems

Reply via email to