Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78363 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 81509 invoked from network); 27 Oct 2014 02:43:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Oct 2014 02:43:49 -0000 Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.192.174 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.192.174 mail-pd0-f174.google.com Received: from [209.85.192.174] ([209.85.192.174:62649] helo=mail-pd0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CF/B3-56216-361BD445 for ; Sun, 26 Oct 2014 21:43:47 -0500 Received: by mail-pd0-f174.google.com with SMTP id p10so4722107pdj.33 for ; Sun, 26 Oct 2014 19:43:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:message-id:date:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=MnC1aGVE6rj20xtj8ppbp/n4Y5wQYcMabC49QqyJkJM=; b=zPcg9EQqIFp/w+JQbPcITXwAAKTi1KDf6nhMxRRVKw3gAXPuibNNDzyqNxgmFQrNbw PUoRLe1wMpK1maEdr8xwz/GMPvV+YN0qN4d5NkI9qNNoPdl9NrbyeyM9/cgtuHMnUKgi P6I9h7sebamIIq8BkRkeOe0PunGXQbOdBNkaOBdEKEkMbK8FafECA+oNFsLsFBp0+rrm sbgXNmHJk0e+6JN7HIUEXlUqsNdG0hYF004aCKCmRtqhWMpR9IF5+TJUQikrd9Th5/Zg cQW1C9ulVF6QC9YJlD35rntWCjMr47XiJQ5LtrWPdgdnRTjIfkAOHzhtr1C7McBgx771 2New== X-Received: by 10.68.106.161 with SMTP id gv1mr2215268pbb.1.1414377823824; Sun, 26 Oct 2014 19:43:43 -0700 (PDT) Received: from Stass-MacBook-Pro.local (108-66-6-48.lightspeed.sntcca.sbcglobal.net. [108.66.6.48]) by mx.google.com with ESMTPSA id y16sm9376896pbt.17.2014.10.26.19.43.42 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Oct 2014 19:43:43 -0700 (PDT) X-Google-Original-From: Stas Malyshev Message-ID: <544DB15E.7090704@php.net> Date: Sun, 26 Oct 2014 19:43:42 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: Will Fitch CC: PHP Internals References: <544DA1CD.9070109@php.net> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] [RFC] Using objects as keys From: smalyshev@gmail.com (Stas Malyshev) Hi! > I’m 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 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. > an object. If the intent is to provide an opportunity of individual > classes to decide what their hash is, couldn’t 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. This is covered in the RFC, right in the introduction. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/