Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78375 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 9771 invoked from network); 27 Oct 2014 07:23:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Oct 2014 07:23:04 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@bof.de; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=php@bof.de; sender-id=pass Received-SPF: pass (pb1.pair.com: domain bof.de designates 80.242.145.70 as permitted sender) X-PHP-List-Original-Sender: php@bof.de X-Host-Fingerprint: 80.242.145.70 mars.intermailgate.com Received: from [80.242.145.70] ([80.242.145.70:40652] helo=mars.intermailgate.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 24/68-56216-6D2FD445 for ; Mon, 27 Oct 2014 02:23:03 -0500 Received: (qmail 14169 invoked by uid 1009); 27 Oct 2014 08:22:58 +0100 Received: from 209.85.192.41 by mars (envelope-from , uid 89) with qmail-scanner-1.25-st-qms (clamdscan: 0.96.2/19534. spamassassin: 3.3.1. perlscan: 1.25-st-qms. Clear:RC:1(209.85.192.41):. Processed in 0.104636 secs); 27 Oct 2014 07:22:58 -0000 X-Antivirus-MYDOMAIN-Mail-From: php@bof.de via mars X-Antivirus-MYDOMAIN: 1.25-st-qms (Clear:RC:1(209.85.192.41):. Processed in 0.104636 secs Process 14155) Received: from mail-qg0-f41.google.com (gmail@bof.de@209.85.192.41) by mars.intermailgate.com with RC4-SHA encrypted SMTP; 27 Oct 2014 08:22:58 +0100 Received: by mail-qg0-f41.google.com with SMTP id q107so1268532qgd.0 for ; Mon, 27 Oct 2014 00:22:56 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.140.39.134 with SMTP id v6mr28465986qgv.19.1414394576907; Mon, 27 Oct 2014 00:22:56 -0700 (PDT) Received: by 10.140.43.68 with HTTP; Mon, 27 Oct 2014 00:22:56 -0700 (PDT) Received: by 10.140.43.68 with HTTP; Mon, 27 Oct 2014 00:22:56 -0700 (PDT) In-Reply-To: <544DEFBE.8090107@sugarcrm.com> References: <544DA1CD.9070109@php.net> <544DEFBE.8090107@sugarcrm.com> Date: Mon, 27 Oct 2014 08:22:56 +0100 Message-ID: To: Stas Malyshev Cc: internals Content-Type: multipart/alternative; boundary=001a11c120e45433b005066266ea Subject: Re: [PHP-DEV] [RFC] Using objects as keys From: php@bof.de (Patrick Schaaf) --001a11c120e45433b005066266ea Content-Type: text/plain; charset=UTF-8 Am 27.10.2014 08:09 schrieb "Stas Malyshev" : > > > 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 did not mean SplObjectStorage would be affected negatively. Just used it as the best known example for something that directly supports objects themselves as keys. Once your proposal is in the language, you will never, in the future, be able to add real support for objects as keys, because the semantics is blocked. I do understand where your proposal is coming from and what it is trying to accomplish. But I think, at least, that it should clearly spell out that any ambition to really support objects as array keys in the base language, will then be given up. > I personally would say SplObjectStorage probably should respect __hash if > provided, but we can discuss it separately. I hardly see how that would make sense. SplObjectStorate operates with object identity as determined by spl_object_hash, right? Changing that to use your key derivation method, would break that contract. Okay, maybe it could make sense by adding a second set of attach/detach methods that work this way when the objects support the new hash method. > 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. Right. Somehow python manages to live quite fine with that fact. > Moreover, modifying such objects would probably create havoc. Right. You don't do that when your object implements __hash__ and __eq__. best regards Patrick --001a11c120e45433b005066266ea--