Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79722 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 15899 invoked from network); 16 Dec 2014 12:53:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Dec 2014 12:53:10 -0000 Authentication-Results: pb1.pair.com header.from=florian@margaine.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=florian@margaine.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain margaine.com from 209.85.213.170 cause and error) X-PHP-List-Original-Sender: florian@margaine.com X-Host-Fingerprint: 209.85.213.170 mail-ig0-f170.google.com Received: from [209.85.213.170] ([209.85.213.170:62025] helo=mail-ig0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9F/70-12185-43B20945 for ; Tue, 16 Dec 2014 07:53:09 -0500 Received: by mail-ig0-f170.google.com with SMTP id r2so7645933igi.5 for ; Tue, 16 Dec 2014 04:53:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=d8exCQ+x38T+5Pq+cHcSPfUzqd86eM7Ks9Hi4N0KWnU=; b=QRi9dzA3zvHJyiYDdfp5x0oXpppQvj4qapLNKLWzlc0XScMgGPyJyjFXHmMCTaCh8C fkZ3qLq5asTWLvzR6tmBfZPeAE5Qy/JXsO1uwcEc5yEmjW9SkbnanzxAQlDXYqWPdD00 aPEqtWO5HxUidhZ8fdT2Q5Fegr3bQr3svqEVGHkru5SmslC26YRzsPE4vv3NfFDd2WTe lp+T1zWzoZDcGKwI3Ahl35xeQqEdNf+g1kuvr4UCquEiORHdv5H17T93F1yJKOWn3z+0 ZP9XJHYLXA+RANAGMqJ7S0LoIq9xQukudHlCQ8cwwd+HItduWvfn49RNPrV69hnhR4F5 3jTg== X-Gm-Message-State: ALoCoQlilokrxFqk49rXUsVsw11B4i042Td/RCzfSLjvds66Mru5WLBtXjwqtyZURaGo41LyXTy3 MIME-Version: 1.0 X-Received: by 10.42.72.138 with SMTP id o10mr30840110icj.73.1418734385666; Tue, 16 Dec 2014 04:53:05 -0800 (PST) Received: by 10.107.30.207 with HTTP; Tue, 16 Dec 2014 04:53:05 -0800 (PST) X-Originating-IP: [82.122.211.32] Received: by 10.107.30.207 with HTTP; Tue, 16 Dec 2014 04:53:05 -0800 (PST) In-Reply-To: <54902917.8010803@gmail.com> References: <548FEE87.7020602@gmail.com> <549009EE.7040808@fischer.name> <5490190A.6050805@beccati.com> <54902917.8010803@gmail.com> Date: Tue, 16 Dec 2014 13:53:05 +0100 Message-ID: To: Rowan Collins Cc: PHP Internals Content-Type: multipart/alternative; boundary=90e6ba3fd28316b46d050a54d792 Subject: Re: [PHP-DEV] [RFC][VOTE] Objects as Keys From: florian@margaine.com (Florian Margaine) --90e6ba3fd28316b46d050a54d792 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi, Le 16 d=C3=A9c. 2014 13:45, "Rowan Collins" a =C3= =A9crit : > > Patrick Schaaf wrote on 16/12/2014 11:46: > >> Am 16.12.2014 12:36 schrieb "Matteo Beccati" : >>> >>> On 16/12/2014 11:52, Andrea Faulds wrote: >>>> >>>> I was previously in favour of this, but it=E2=80=99d prevent actual in= dexing >>>> by objects in future, and I can=E2=80=99t think of any use cases which= aren=E2=80=99t >>>> better solved by explicitly converting to a string/integer. >>> >>> That's precisely the same reason why I voted Nay. And I wouldn't have >> >> been able to put it down in words better than Andrea did. >> >> That was my thought initially, too. But I think it is wrong. If PHP ever >> gets around to provide objects-themselves-as-array-keys support, it can >> easily do that >> >> 1) only if the object does not have such a __toKey() method, or >> 2) if the object has one, but it returns the object itself (which is >> forbidden now by the RFC) > > > Hm, that's an interesting thought. My thought had been that an object-as-key would need to specify its hash anyway, so that two objects of the same "value" would be automatically de-duped, just as two strings are. But I guess an internally unique handle for the specific object would also be a reasonable approach for some uses. Just a random thought: the `__hash` method can just `return spl_object_hash($this);` to have an object id. > -- > Rowan Collins > [IMSoP] > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > Cheers, Florian Margaine --90e6ba3fd28316b46d050a54d792--