Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78383 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 25984 invoked from network); 27 Oct 2014 09:15:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Oct 2014 09:15:09 -0000 Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 198.187.29.245 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 198.187.29.245 imap11-3.ox.privateemail.com Received: from [198.187.29.245] ([198.187.29.245:35062] helo=imap11-3.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C1/7B-56216-B1D0E445 for ; Mon, 27 Oct 2014 04:15:08 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id 4F3F48800ED; Mon, 27 Oct 2014 05:15:04 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at imap11.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap11.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id GuRRlCH9XgZY; Mon, 27 Oct 2014 05:15:04 -0400 (EDT) Received: from oa-edu-168-124.wireless.abdn.ac.uk (oa-edu-168-124.wireless.abdn.ac.uk [137.50.168.124]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id DCD728800F4; Mon, 27 Oct 2014 05:15:02 -0400 (EDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.0 \(1990.1\)) In-Reply-To: <544DE7FF.6030809@gmail.com> Date: Mon, 27 Oct 2014 09:15:00 +0000 Cc: Joe Watkins , PHP Internals Content-Transfer-Encoding: quoted-printable Message-ID: References: <544DA1CD.9070109@php.net> <1414388245.2624.135.camel@localhost.localdomain> <544DE7FF.6030809@gmail.com> To: Stas Malyshev X-Mailer: Apple Mail (2.1990.1) Subject: Re: [PHP-DEV] [RFC] Using objects as keys From: ajf@ajf.me (Andrea Faulds) > On 27 Oct 2014, at 06:36, Stas Malyshev wrote: >=20 > Hi! >=20 >> It seems __toScalar might be a good name, this is what the method >> actually does, the engine then coerces to a type suitable for use as = a >> key, but you can return a double. It might be more forward thinking >> therefore to use the name __toScalar, while today we'd only be using >> it for this,=20 > __toScalar does not express the fact why we are calling it - to use it > as a key. It's not just a scalar conversion, it's conversion for the > purpose of hashing. It would also be used by Anthony=E2=80=99s Object Cast To Types = (https://wiki.php.net/rfc/object_cast_to_types) RFC if revived, and = __toScalar makes more sense there. Personally, I think __toKey is best. It=E2=80=99s not a hash as such, = it=E2=80=99s an equivalent string or integer key value. It fits nicely = with __toString, and would fit with other __to* functions like __toInt = if that RFC was revived. People would look at __hash and think it=E2=80=99= s sql_object_hash, which it isn=E2=80=99t. -- Andrea Faulds http://ajf.me/