Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:77589 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 80437 invoked from network); 24 Sep 2014 19:56:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Sep 2014 19:56:56 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@sugarcrm.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@sugarcrm.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain sugarcrm.com designates 108.166.43.99 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 108.166.43.99 smtp99.ord1c.emailsrvr.com Linux 2.6 Received: from [108.166.43.99] ([108.166.43.99:35285] helo=smtp99.ord1c.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2E/B3-57585-70223245 for ; Wed, 24 Sep 2014 15:56:56 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp5.relay.ord1c.emailsrvr.com (SMTP Server) with ESMTP id 24110180119; Wed, 24 Sep 2014 15:56:53 -0400 (EDT) X-Virus-Scanned: OK Received: by smtp5.relay.ord1c.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id B4AD9180490; Wed, 24 Sep 2014 15:56:52 -0400 (EDT) X-Sender-Id: smalyshev@sugarcrm.com Received: from Stass-MacBook-Pro.local ([UNAVAILABLE]. [74.85.23.222]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA) by 0.0.0.0:465 (trex/5.2.13); Wed, 24 Sep 2014 19:56:53 GMT Message-ID: <54232205.4020806@sugarcrm.com> Date: Wed, 24 Sep 2014 12:56:53 -0700 Organization: SugarCRM User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:31.0) Gecko/20100101 Thunderbird/31.1.1 MIME-Version: 1.0 To: =?UTF-8?B?Sm9oYW5uZXMgU2NobMO8dGVy?= , Nicolai Scheer CC: PHP Internals References: <1411561476.2303.4.camel@guybrush> In-Reply-To: <1411561476.2303.4.camel@guybrush> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Invokation on __toString() for object used as array key From: smalyshev@sugarcrm.com (Stas Malyshev) Hi! > There the assumption would be that this leads to an array $a with two > elements, where in fact there is only one if __toString() is being > called. The only thing "making sense" would be using using the objects > identity (i.e. via spl_object_hash()) everything else leads to issues. This is a valid concern. For this, Java, for example, has separate methods hashCode() and toString(). Python has __str__, __repr__ and __hash__. Ruby has object.hash. So maybe we should have another magic, something like __hash(), that would produce a value for key? Then objects that implement __hash would be hashable and those that don't won't be, while still having usable __toString. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/