Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:31247 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13982 invoked by uid 1010); 24 Jul 2007 23:53:29 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 13967 invoked from network); 24 Jul 2007 23:53:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Jul 2007 23:53:29 -0000 Authentication-Results: pb1.pair.com header.from=helly@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=helly@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 85.214.94.56 as permitted sender) X-PHP-List-Original-Sender: helly@php.net X-Host-Fingerprint: 85.214.94.56 aixcept.net Linux 2.6 Received: from [85.214.94.56] ([85.214.94.56:50405] helo=h1149922.serverkompetenz.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 03/97-14257-7F096A64 for ; Tue, 24 Jul 2007 19:53:29 -0400 Received: from MBOERGER-ZRH.corp.google.com (ip2.fa1-0-2.occ.iinet.com [198.145.33.2]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by h1149922.serverkompetenz.net (Postfix) with ESMTP id 495601B3612; Wed, 25 Jul 2007 01:53:22 +0200 (CEST) Date: Wed, 25 Jul 2007 01:53:25 +0200 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <537685038.20070725015325@marcus-boerger.de> To: Stanislav Malyshev CC: Sebastian Bergmann , internals@lists.php.net In-Reply-To: <46893B43.1020907@zend.com> References: <468519DC.8060502@widescreen.ch> <585221804.20070701154538@marcus-boerger.de> <002701c7bc28$8279c2c0$876d4840$@com> <4688808A.7030706@zend.com> <46893931.1020000@zend.com> <46893B43.1020907@zend.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] toString() and Object #ID From: helly@php.net (Marcus Boerger) Hello all, and thanks Stas for the explanations. Monday, July 2, 2007, 7:52:03 PM, you wrote: >> We could add a counter that gets incremented for each object that is >> created and associate that number with the object. Wouldn't that solve >> the problem (if there is one)? > It would solve it, but it would require modifying each extension dealing > with objects in order to register all objects in this global registry > and of course it would require adding another value into object > structure. I'm not sure having running numeric ID is that important. > If you just need to know if two variables are the same object, you have > ===. If you need to index by it, you have the hash. Exactly. And the index should not be dependant on the contents of the properties. Also you should always use the shortest unique ID. In our case as very well explained it is handler plus id. What we could do to prevent two different objects getting the same hash is to ask for the memory location....but the we cannot use the zval container as multiple zval containers might point to the same object. Nor can we really use the object location in its object storage as we do not know if that is safe. Thus we could only add an independent counter which imo is pretty bad and as epxplained it would created overly complex overhead. Now what you actually want with the hash is indexing. That probably means storing the object in whatever holds the index - maybe an array. Maybe something else. Either way no other object can get the same hash as the object is stored and thus no other objetc can get the same handler,id combo at the same time. So i do not see any issue here. If you guys want it more complex i suggest you extend the hash in userland and add a special property/interface solution. Best regards, Marcus