Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78393 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 61157 invoked from network); 27 Oct 2014 16:16:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Oct 2014 16:16:07 -0000 Authentication-Results: pb1.pair.com smtp.mail=linepogl@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=linepogl@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.50 as permitted sender) X-PHP-List-Original-Sender: linepogl@gmail.com X-Host-Fingerprint: 209.85.218.50 mail-oi0-f50.google.com Received: from [209.85.218.50] ([209.85.218.50:35716] helo=mail-oi0-f50.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4B/01-56216-6CF6E445 for ; Mon, 27 Oct 2014 11:16:06 -0500 Received: by mail-oi0-f50.google.com with SMTP id i138so3673368oig.9 for ; Mon, 27 Oct 2014 09:16:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=6h8FMLrEXXBjO+NtJMxy6m2WDRGeB3Mty78iY8tPK+8=; b=Mw1YeeufRSW7QOQI7uR0+Ei5z9LPpizMuIiF7TLFtuRYc920P6fZ3+2FPg7alB7XJN B6N/ETB39TjoqeQbk4F2+LK4P/5fVgNhMNX9nN/gLRWjftnbIi9fNMA+EewUR1xcG2uE TDu1IqKZPnfXqTPOooIaUCMuY3cUX/C8JahTdNXBgZjPcIMSVBPqGSPXBOsn1lqIxvhb Sh5tIGJ81CYk18oT2D6FZ2hqnhN0MbguqnM3yTFV2rUsBWcUe2TLL8stjIuBES6RoG// 1/9FpujTQ8+hFNMlGIIbEYJabm5TdiIaVjYKgrAC1+p13OiFV2gWGwUixjmWTUrfC1uM MMXw== X-Received: by 10.60.98.203 with SMTP id ek11mr20974022oeb.29.1414426563492; Mon, 27 Oct 2014 09:16:03 -0700 (PDT) MIME-Version: 1.0 Received: by 10.76.160.74 with HTTP; Mon, 27 Oct 2014 09:15:42 -0700 (PDT) In-Reply-To: References: <544DA1CD.9070109@php.net> Date: Mon, 27 Oct 2014 17:15:42 +0100 Message-ID: To: Levi Morrison Cc: Stas Malyshev , PHP Internals Content-Type: multipart/alternative; boundary=089e01182b72e0c0f1050669d81a Subject: Re: [PHP-DEV] [RFC] Using objects as keys From: linepogl@gmail.com (Lazare Inepologlou) --089e01182b72e0c0f1050669d81a Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 2014-10-27 16:54 GMT+01:00 Levi Morrison : > > I would like to present to your attention an RFC about using object as > keys: > > > > https://wiki.php.net/rfc/objkey > > A few points I have against this proposal, as I understand it: > > - It does not store the object, only the result of `__hash`. > Without the actual object this is not helpful for any use-case I have. > > - Using a method in the object prevents you from hashing on > different members of the objects for different uses. For example, > there is a User object. Most of the time the User::id will be used for > the hash. However, sometimes the hash needs to be on User::username. > If the hashing code is pushed inside the object and call it > automatically then you can't hash on the different values. > > In summary 1) the hashing function should be external to the object, > 2) should not be invoked magically, and 3) the object needs to be > stored. This can already be done in user-land; here is one such > example that I have created but there are others: > https://github.com/morrisonlevi/Ardent/blob/master/src/HashMap.php > > Although I don't care very much for the first two points, the third point is very alarming. Yes, we should have the option to get the objects used as keys, otherwise the new functionality does not offer much. Lazare INEPOLOGLOU Ing=C3=A9nieur Logiciel --089e01182b72e0c0f1050669d81a--