Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78364 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 83546 invoked from network); 27 Oct 2014 03:08:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Oct 2014 03:08:29 -0000 Authentication-Results: pb1.pair.com header.from=willfitch@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=willfitch@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 66.111.4.25 as permitted sender) X-PHP-List-Original-Sender: willfitch@php.net X-Host-Fingerprint: 66.111.4.25 out1-smtp.messagingengine.com Received: from [66.111.4.25] ([66.111.4.25:60586] helo=out1-smtp.messagingengine.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7A/14-56216-C27BD445 for ; Sun, 26 Oct 2014 22:08:28 -0500 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id A7416207E6 for ; Sun, 26 Oct 2014 23:08:25 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute2.internal (MEProxy); Sun, 26 Oct 2014 23:08:25 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=x-sasl-enc:content-type:mime-version :subject:from:in-reply-to:date:cc:content-transfer-encoding :message-id:references:to; s=smtpout; bh=9+AZRx13sY2P02gtn4jAWwt qlSg=; b=fJGRo4AHNet3gqSRit3WJoCfutOhi8sYbdyw3AGlJV9fhMpLZKIlPpn R3PFOMDnAsDiPnO/bKQzzkRpNLGQXMIouRe9gmsCrkPAvkh5HI4oT44ZDqlwSYG+ u00I9MRcXEkFV9ccSroNwCa8dcThdb01AcRM96IthFv3U7y4lOJg= X-Sasl-enc: /IA/HxHd5mExqzs6bx/MGaskw7itic0wsGPU62y6rEyN 1414379305 Received: from [192.168.1.137] (unknown [24.183.225.156]) by mail.messagingengine.com (Postfix) with ESMTPA id 54CCBC00013; Sun, 26 Oct 2014 23:08:25 -0400 (EDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.0 \(1990.1\)) In-Reply-To: <544DB15E.7090704@php.net> Date: Sun, 26 Oct 2014 22:08:24 -0500 Cc: PHP Internals Content-Transfer-Encoding: quoted-printable Message-ID: <4F8CEEE9-33CF-4138-9280-5488992C4AAB@php.net> References: <544DA1CD.9070109@php.net> <544DB15E.7090704@php.net> To: Stas Malyshev X-Mailer: Apple Mail (2.1990.1) Subject: Re: [PHP-DEV] [RFC] Using objects as keys From: willfitch@php.net (Will Fitch) > On Oct 26, 2014, at 9:43 PM, Stas Malyshev = wrote: >=20 > Hi! >=20 >> I=E2=80=99m trying to wrap my head around a real-world use-case with = this. >> We have spl_object_hash, which effectively provides a unique hash for >=20 > This hash has nothing to do with object's contents. But imagine number > GMP("42") and imagine you actually want two GMP objects expressing = "42" > actually represent the same hash key. Or imagine you want to generate > the key somehow in a way related to object's content and not just a > random number. As I said in the RFC, evidence that so many languages > implement it shows that this use case is quite real. Of course, you = can > always default to spl_object_hash, but now you have control over it. Thank you for your clarity. With this new approach, wouldn=E2=80=99t we = best be served by renaming/deprecating/removing spl_object_hash? I=E2=80=99= m concerned these different approaches will introduce quite a bit of = confusion with object hashing. This RFC=E2=80=99s approach gives the = user more power to determine what=E2=80=99s best in this case, so I=E2=80=99= d lean more towards renaming spl_object_hash to something that reflects = getting a unique ID per object (e.g. spl_unique_object_id, etc). >=20 >> an object. If the intent is to provide an opportunity of individual >> classes to decide what their hash is, couldn=E2=80=99t they provide = that via >> __toString? I know many frameworks use __toString to build out some >> implementation of an object (Zend form for example), but the point of >> __toString is to provide a string representation of an object. >=20 > This is covered in the RFC, right in the introduction. > --=20 > Stanislav Malyshev, Software Architect > SugarCRM: http://www.sugarcrm.com/