Re: [RFC][VOTE] Objects as Keys

From: Date: Thu, 18 Dec 2014 14:52:43 +0000
Subject: Re: [RFC][VOTE] Objects as Keys
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15  Groups: php.internals 
Request: Send a blank email to internals+get-79807@lists.php.net to get a copy of this message
Lester Caine wrote: > On 18/12/14 09:03, Stanislav Malyshev wrote: >>> Luckily, we have SplObjectStorage, which maybe makes that rather less >>>> urgent as well. >> SplObjectStorage doesn't do this - SplObjectStorage uses objects' >> identity, which means two GMP(1)'s are different objects. > > Silly question time again ... > > What 'precisely' is the problem that 'Objects as keys' is trying to > solve? Stas explained that in a blog post: <http://php100.wordpress.com/2014/12/14/objects-as-keys/>. > I think what I am asking is just how should a 'modern' design > using OO actually build a multidimentional array of objects? > > What I am currently doing is building a conventional array of which one > element is the attached object. Other elements of the array include the > primary key and other data useful for sorting the order along with > identifying cross links to other objects. I can get to the underlying > object just by looking up the primary key in the array. > > Where does SplObjectStorage fit into this, and more important how does > creating a new object fit in with adding it as a key in an array. I need > the handle to the object and I ideally I need to know what is in the > object so I seem to be missing something. IMHO that is better asked and discussed on php-general@lists.php.net. -- Christoph M. Becker

« previous php.internals (#79807) next »