@Ryan which is existing behaviour in language. Because object is immutable I don't think we should care anymore about 'references' instead maybe we could focus on value that object represents.
2016-11-16 15:29 GMT+01:00 Ryan Pallas <[email protected]>: > > > On Wed, Nov 16, 2016 at 6:57 AM, Silvio Marijić <[email protected]> > wrote: > >> Hi, >> >> To anyone who is interested in this RFC. What do you think what behavour >> we >> should have when you try to compare two immutable objects by identity like >> this: >> >> immutable class A { >> >> public $a; >> >> public function __construct($a) { >> $this->a = $a >> } >> >> } >> >> $a1 = new A(1); >> $a2 = new A(1); >> > > I would personally expect that: > > var_dump($a1 === $a2); // bool(false) > var_dump($a1 == $a2); // bool(true) > > >> >> $a1 === $a2 >> >> If we treat those objects as values then this should return true. But then >> again there might be some confusion because then two operators are doing >> the same thing. Maybe throw an error ? Suggestions ? >> >> Cheers. >> -- >> Silvio Marijić >> Software Engineer >> 2e Systems >> > > -- Silvio Marijić Software Engineer 2e Systems
