Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:23943 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 794 invoked by uid 1010); 4 Jun 2006 16:17:37 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 776 invoked from network); 4 Jun 2006 16:17:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Jun 2006 16:17:37 -0000 X-PHP-List-Original-Sender: rasmus@lerdorf.com X-Host-Fingerprint: 204.11.219.139 lerdorf.com Linux 2.5 (sometimes 2.4) (4) Received: from ([204.11.219.139:38690] helo=lerdorf.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 79/4F-49656-0A703844 for ; Sun, 04 Jun 2006 12:17:36 -0400 Received: from [192.168.200.106] (c-24-6-5-134.hsd1.ca.comcast.net [24.6.5.134]) (authenticated bits=0) by lerdorf.com (8.13.6/8.13.6/Debian-1) with ESMTP id k54GHW98015413; Sun, 4 Jun 2006 09:17:32 -0700 Message-ID: <4483079C.90007@lerdorf.com> Date: Sun, 04 Jun 2006 09:17:32 -0700 User-Agent: Thunderbird 3.0a1 (Macintosh/20060414) MIME-Version: 1.0 To: Andi Gutmans CC: Derick Rethans , Marcus Boerger , internals@lists.php.net References: <795156743.20060603134212@marcus-boerger.de> <509342741.20060603183859@marcus-boerger.de> <7.0.1.0.2.20060603175211.02208a50@zend.com> <20060604030100.1093d2f9@pierre-u64> <7.0.1.0.2.20060603181129.0396fc18@zend.com> <44823B41.5000608@akbkhome.com> <44823C51.7040408@lerdorf.com> <64299052.20060604120852@marcus-boerger.de> <20060604135241.3beacb32@pierre-u64> <1853717276.20060604140317@marcus-boerger.de> <1912643046.20060604141822@marcus-boerger.de> <7.0.1.0.2.20060604071847.03b74850@zend.com> <1834492302.20060604165624@marcus-boerger.de> <7.0.1.0.2.20060604075725.03d77b20@zend.com> <1996647038.20060604170829@marcus-boerger.de> <7.0.1.0.2.20060604081244.03dcd938@zend.com> <334553601.20060604171820@marcus-boerger.de> <7.0.1.0.2.20060604083343.034abe88@zend.com> <7.0.1.0.2.20060604085729.0343f788@zend.com> In-Reply-To: <7.0.1.0.2.20060604085729.0343f788@zend.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Missing __toString() part From: rasmus@lerdorf.com (Rasmus Lerdorf) Andi Gutmans wrote: > Again, I don't think we should have a hash but a unique id which can be > used as an array key and in other things. Difference. Hash implies that > it's not unique, I'm talking about unique. So yes, I'd take the starting > point of Marcus' proposal but: > a) Make the value start with a letter so that this isn't autoconverted > but taken as a literal string key. Again, something like "id=%p:%d" > b) Not call it hash because I see this as a unique id and not as a hash > value which is not unique necessarily. > c) This should be something outside SPL and part of the engine. Question > is again, whether it's explicit or implicit (back to the question I had > earlier). Do you just want to add a function which returns this thing or > do you want $arr[$obj] to automatically ask for it. > > These are valid questions and should be answered. I think if we implement a way to get a hash from an object, or at least a unique identifier that can be used as a hash, then it should be implicit just like other things are implicitly converted when the context is clear. Of course, you should also be able to force it explicitly. And I don't think there is any point in doing this unless we also implicitly go the other way. From unique identifier to object. As in: class foo { function bar($arg) { echo $arg; } } $obj1 = new foo; $obj2 = new foo; $a = array($obj1=>1,$obj2=>2); foreach($a as $k=>$v) { $k->bar($v); } Unless this works, I am not sure there is any point to all this. To me the end goal is to make it possible to use types other than strings and numbers as array indices which to me also means we should look at doing the same for arrays. -Rasmus