Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78397 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 75223 invoked from network); 27 Oct 2014 17:40:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Oct 2014 17:40:02 -0000 Authentication-Results: pb1.pair.com smtp.mail=ekneuss@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ekneuss@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.174 as permitted sender) X-PHP-List-Original-Sender: ekneuss@gmail.com X-Host-Fingerprint: 209.85.217.174 mail-lb0-f174.google.com Received: from [209.85.217.174] ([209.85.217.174:63693] helo=mail-lb0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3C/B3-56216-0738E445 for ; Mon, 27 Oct 2014 12:40:01 -0500 Received: by mail-lb0-f174.google.com with SMTP id p9so6151984lbv.19 for ; Mon, 27 Oct 2014 10:39:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=gWFD6aGXbwTYSQJF+c4cM+S49pM0dbLtyWZfzA5yqhk=; b=PUQZz1TIrrQ/MXr1zBuKHEF5tiQnrCZvFrx5lZqHJjtsxzrsFmEZxJZm+wjKyurh8o /pjgrBZ0X1QMbCLP0OZBgfXvBNQgLJBMewxBBnw7LZ37A6QaOrlCY+uE2ex6akldBfVL /AATzz6aGNuyTdkSviu0iZc9JqLe4O/2cMs/lKbT4MsaTEjXRLiSYAvDtkMWXU/zQ+vA S7FftetCwu8Jrit7NARRAJLFXSdq/Of1xuPu/qQjIYo/ZbDyL/C2+MkkEXZhyM6PXUBl bSV083tsS7Jo5X43pixFGBsSqzQj07aDK69WSYuwAMtNqoAmvQkJHDGB7kbv0J6OJVGs 6sJA== X-Received: by 10.152.121.68 with SMTP id li4mr24838141lab.77.1414431597101; Mon, 27 Oct 2014 10:39:57 -0700 (PDT) MIME-Version: 1.0 Sender: ekneuss@gmail.com Received: by 10.25.79.72 with HTTP; Mon, 27 Oct 2014 10:39:26 -0700 (PDT) In-Reply-To: <544DA1CD.9070109@php.net> References: <544DA1CD.9070109@php.net> Date: Mon, 27 Oct 2014 18:39:26 +0100 X-Google-Sender-Auth: 5OwhFUdVxJeRQnhFYpGw56nPrf4 Message-ID: To: Stas Malyshev Cc: PHP Internals Content-Type: multipart/alternative; boundary=089e0117767de7885b05066b0419 Subject: Re: [PHP-DEV] [RFC] Using objects as keys From: etienne.kneuss@epfl.ch (Etienne Kneuss) --089e0117767de7885b05066b0419 Content-Type: text/plain; charset=UTF-8 On Mon, Oct 27, 2014 at 2:37 AM, Stas Malyshev wrote: > Hi! > > I would like to present to your attention an RFC about using object as > keys: > > https://wiki.php.net/rfc/objkey > > I think it should be made clear that what the target of your RFC is not to support objects as keys, what you propose instead is an implicit translation from: $a[$obj] to $a[$obj->__hash()] This is clearly different. And has at least one major drawback: The object itself is not in the array, you cannot retrieve it by foreach($arr as $obj => $v) { }. => This is quite counter-intuitive and counter-productive: one would expect to find the object there, not its "hash". As others noted, it also prevents a full-fledged objects-as-key implementation in the future. In the end it causes issues and brings very little compared to an explicit call to convert an object to a key. -1 -- Etienne Kneuss --089e0117767de7885b05066b0419--