Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:77593 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 86906 invoked from network); 24 Sep 2014 20:13:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Sep 2014 20:13:07 -0000 Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 192.64.116.208 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.208 imap2-3.ox.privateemail.com Received: from [192.64.116.208] ([192.64.116.208:52814] helo=imap2-3.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3C/25-57585-1D523245 for ; Wed, 24 Sep 2014 16:13:06 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id B8E178C0075; Wed, 24 Sep 2014 16:13:01 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at imap2.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap2.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id hJtl-gisDggN; Wed, 24 Sep 2014 16:13:01 -0400 (EDT) Received: from oa-res-27-90.wireless.abdn.ac.uk (oa-res-27-90.wireless.abdn.ac.uk [137.50.27.90]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id DB4118C007D; Wed, 24 Sep 2014 16:12:58 -0400 (EDT) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) In-Reply-To: <542324D0.6050407@sugarcrm.com> Date: Wed, 24 Sep 2014 21:12:55 +0100 Cc: =?windows-1252?Q?Johannes_Schl=FCter?= , Nicolai Scheer , PHP Internals Content-Transfer-Encoding: quoted-printable Message-ID: <18FA619F-0476-4814-81E6-F004BDF2775E@ajf.me> References: <1411561476.2303.4.camel@guybrush> <54232205.4020806@sugarcrm.com> <3E4C58C8-E816-4798-9D8F-2C7EFFA28438@ajf.me> <542324D0.6050407@sugarcrm.com> To: Stas Malyshev X-Mailer: Apple Mail (2.1878.6) Subject: Re: [PHP-DEV] Invokation on __toString() for object used as array key From: ajf@ajf.me (Andrea Faulds) On 24 Sep 2014, at 21:08, Stas Malyshev wrote: > The hash doesn't have to be a nonsensical hex value, it can be = something > like "My Object Number 42" if you want to. The difference is that > __toString is for human reading, and it's not always suitable for > hashing purposes. Just read the docs on any of the languages that have > separate hash method - they all have the same argument, there's a > different between printing an object for output and using the object = as > a key. Actually, yeah, I see your point. I suggest this, then: public function __toKey() : int | string {} Psuedo-code, since you can=92t have multiple return types. I think it=92s = a better name than __hash (fits well with __toString IMO), and this way = we can support integer keys too, where that makes sense. -- Andrea Faulds http://ajf.me/