Re: Re: Arrays which have properties of sets

From: Date: Sun, 07 Oct 2012 23:51:48 +0000
Subject: Re: Re: Arrays which have properties of sets
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-63273@lists.php.net to get a copy of this message
On Sun, Oct 7, 2012 at 7:12 PM, Rasmus Schultz <rasmus@mindplay.dk> wrote: > the manual states, "The implementation in SplObjectStorage returns the > same value as spl_object_hash()" - so I don't know how this would > really work any better than a custom implementation. > > perhaps safer would be to simply implement a collection-type that > requires the classes of elements in the collection to implement an > interface, exposing a unique key... and for objects that don't have a > unique key, generate sequential keys from a static counter in each > class... not ideal if you want to implement a document store that can > store "anything", since now every stored object/class needs to provide > a key... > How is that safer? If anything this introduces every aspect of being unsafe since relies on a user implementation that may or may not exist and may or may not be unique. As opposed to spl_object_hash, which can actually identify objects uniquely by looking at the internal symbol table that exposes all the objects in memory. > On Sun, Oct 7, 2012 at 4:06 PM, Jared Williams > <jared.williams1@ntlworld.com> wrote: >> >> See SPL's SplObjectStorage. That allows object instances as keys. >> >> Jared > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.internals (#63273) next »