Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79708 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 88467 invoked from network); 16 Dec 2014 10:52:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Dec 2014 10:52:28 -0000 Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 192.64.116.200 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.200 imap1-2.ox.privateemail.com Received: from [192.64.116.200] ([192.64.116.200:59827] helo=imap1-2.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 50/62-07463-9EE00945 for ; Tue, 16 Dec 2014 05:52:27 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id 95E8BB00085; Tue, 16 Dec 2014 05:52:22 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at imap1.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap1.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id VLd7RNqfonX1; Tue, 16 Dec 2014 05:52:22 -0500 (EST) Received: from oa-res-26-240.wireless.abdn.ac.uk (oa-res-26-240.wireless.abdn.ac.uk [137.50.26.240]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id 76194B00096; Tue, 16 Dec 2014 05:52:21 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.1 \(1993\)) In-Reply-To: <549009EE.7040808@fischer.name> Date: Tue, 16 Dec 2014 10:52:19 +0000 Cc: internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: References: <548FEE87.7020602@gmail.com> <549009EE.7040808@fischer.name> To: Markus Fischer X-Mailer: Apple Mail (2.1993) Subject: Re: [PHP-DEV] [RFC][VOTE] Objects as Keys From: ajf@ajf.me (Andrea Faulds) Hi Markus, > On 16 Dec 2014, at 10:31, Markus Fischer wrote: >=20 > On 16.12.14 09:34, Stanislav Malyshev wrote: >> I'd like to initiate a vote on "objects as keys" RFC: >> https://wiki.php.net/rfc/objkey >=20 > Am I right this only covers the transformation into the array. Once = it's > in it's essential a array compatible key entity (string/integer) so = when > you var_dump($array) you only get the values of a hash. >=20 > In other words: it would not be possible to actually get the object = from > the key, just this string/integer which is supposed to reference it? Exactly. If I were to do this: foo =3D $foo; } function __toKey() { return $this->foo; } } $arr =3D []; $arr[] =3D new Foo(1); var_dump($arr); I would get this: array(1) { [0]=3D> int(1) } This is the main problem with the RFC: magic, implicit, one-way data = loss (object to integer/string). I was previously in favour of this, but it=E2=80=99d prevent actual = indexing 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. Thanks. -- Andrea Faulds http://ajf.me/