Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79777 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 91306 invoked from network); 17 Dec 2014 13:15:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Dec 2014 13:15:01 -0000 Authentication-Results: pb1.pair.com header.from=etienne.kneuss@epfl.ch; sender-id=softfail Authentication-Results: pb1.pair.com smtp.mail=ekneuss@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.43 as permitted sender) X-PHP-List-Original-Sender: ekneuss@gmail.com X-Host-Fingerprint: 209.85.215.43 mail-la0-f43.google.com Received: from [209.85.215.43] ([209.85.215.43:62041] helo=mail-la0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5B/50-23459-2D181945 for ; Wed, 17 Dec 2014 08:14:59 -0500 Received: by mail-la0-f43.google.com with SMTP id s18so13004195lam.2 for ; Wed, 17 Dec 2014 05:14:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:references:from:date:message-id:subject:to:cc :content-type; bh=xa2Ug45V2hICl8JwPW9hvtRN4htuS+GCOvU/b/hUWPA=; b=JK2sQM/eEYy/N0dDEf0T2I0EXkTL3pnoISYC8Wh2NryYxR3ZNAqiMvk6HmoR7Vm8MI 1PSJguMwbu7tBVMEAchw0IhCdA6TAhqwe7zyAT/f+dVsYfXvZ6spX0jgqKzcC3tPHGrq T1mEzv1TYlxWfk9IOCuM8XWMB/oO+hmp1Z6awcSoFUiwDmgYGaWGZCOqFviHyL7p4UHW uA9Z8VUoN0z7IL+xurKOFMuqVH3D1dzrULNKvETS8wbWhTENW/XkI/Gvw+MdbCWlgmrA acwJTB5yBvytBbsOOwNlh/cvqw7PEysyMkVVvmDf0lfq1SVNm7OtoZWHWWcMvEeJIVh/ m03g== X-Received: by 10.112.202.71 with SMTP id kg7mr40251543lbc.16.1418822095999; Wed, 17 Dec 2014 05:14:55 -0800 (PST) MIME-Version: 1.0 References: <548FEE87.7020602@gmail.com> Date: Wed, 17 Dec 2014 13:14:55 +0000 Message-ID: To: "guilhermeblanco@gmail.com" , Derick Rethans Cc: Stanislav Malyshev , PHP Internals Content-Type: multipart/alternative; boundary=001a11c3714a08192f050a6943cf Subject: Re: [PHP-DEV] [RFC][VOTE] Objects as Keys From: etienne.kneuss@epfl.ch (Etienne Kneuss) --001a11c3714a08192f050a6943cf Content-Type: text/plain; charset=UTF-8 On Wed Dec 17 2014 at 1:44:13 PM guilhermeblanco@gmail.com < guilhermeblanco@gmail.com> wrote: > Hi, > > Answering the question of Christopher Becker. It is not possible to > traverse and get your desired elements. > How would you achieve a foreach by key (returning object) without having to > store a separate list and track by hash or through an interface? > > Which is one of the main problem with this very RFC. What ends up being stored in the array is the hash, not the object. And there is no immediate way of getting the key object back. The user writes: $arr = array($obj => 2); but key($arr) returns the hash only. As I said in the original discussion: this RFC is actually about having an implicit call to __hash() whenever an object is used as an array key. You can achieve exactly the same in userland with an explicit call. I would rather wait (maybe indefinitely) to have a proper implementation of objects as keys than have this compromise. Best, --001a11c3714a08192f050a6943cf--