Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78374 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 7914 invoked from network); 27 Oct 2014 07:09:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Oct 2014 07:09:55 -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:50554] helo=smtp99.ord1c.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1B/08-56216-2CFED445 for ; Mon, 27 Oct 2014 02:09:54 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp21.relay.ord1c.emailsrvr.com (SMTP Server) with ESMTP id ADF1A38018E; Mon, 27 Oct 2014 03:09:51 -0400 (EDT) X-Virus-Scanned: OK Received: by smtp21.relay.ord1c.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id 44858380178; Mon, 27 Oct 2014 03:09:51 -0400 (EDT) X-Sender-Id: smalyshev@sugarcrm.com Received: from Stass-MacBook-Pro.local (108-66-6-48.lightspeed.sntcca.sbcglobal.net [108.66.6.48]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA) by 0.0.0.0:465 (trex/5.3.2); Mon, 27 Oct 2014 07:09:51 GMT Message-ID: <544DEFBE.8090107@sugarcrm.com> Date: Mon, 27 Oct 2014 00:09:50 -0700 Organization: SugarCRM User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: Patrick Schaaf , Stas Malyshev CC: internals References: <544DA1CD.9070109@php.net> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Using objects as keys From: smalyshev@sugarcrm.com (Stas Malyshev) Hi! > I don't like this, mainly because it blocks a future direct use and storage > of objects as keys in an array, i.e. what SplObjectStorage does. It does not. It just allows the objects to control how they are seen when they are used as keys in regular PHP arrays. That does not prevent SplObjectStorage or anything else from doing whatever one wants. I personally would say SplObjectStorage probably should respect __hash if provided, but we can discuss it separately. > It is also badly named, because it does NOT implement objects as keys. It > implements deriving surrogate keys from objects when used in an array key > context. That's how the objects are used as keys. Storing objects in the hashtable would really require rewriting the whole hashtable and would probably be very inefficient as you'd have to call PHP code each time you compare two objects in the chain. Moreover, modifying such objects would probably create havoc. So having an immutable value sounds like the best solution for the practical use cases. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/