Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78453 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16196 invoked from network); 30 Oct 2014 07:19:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Oct 2014 07:19:55 -0000 Authentication-Results: pb1.pair.com smtp.mail=willfitch@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=willfitch@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 66.111.4.27 as permitted sender) X-PHP-List-Original-Sender: willfitch@php.net X-Host-Fingerprint: 66.111.4.27 out3-smtp.messagingengine.com Received: from [66.111.4.27] ([66.111.4.27:38476] helo=out3-smtp.messagingengine.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 85/41-05450-696E1545 for ; Thu, 30 Oct 2014 02:19:55 -0500 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 5D436209BF for ; Thu, 30 Oct 2014 03:19:48 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute5.internal (MEProxy); Thu, 30 Oct 2014 03:19:48 -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=q5W8LPZvoEEiJ7uBDYbLU6W joyo=; b=BRM7AfxdNHssIWXPU38mCBtQot7+23ALHjKR+uYtqOYh5vm/qvsM5w/ r8hM15bdCjFj8DQSzRRbLMIVdJ37hC88NDxlI7gC4PKNiTuO9JsM7CwVPjK+bkjY 7HNfZxcuRFuJa2LzvB6DwsGe5iiTpil1C3yP4awaAEun72n13zNc= X-Sasl-enc: X9Ox/YPJae4I1OiJnvmOtqOzl2xw4lZ2dQBoYFqUFOiB 1414653588 Received: from [192.168.1.137] (unknown [24.183.225.156]) by mail.messagingengine.com (Postfix) with ESMTPA id D120BC00013; Thu, 30 Oct 2014 03:19:47 -0400 (EDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.0 \(1990.1\)) In-Reply-To: <4ED7146272E04A47B986ED49E771E347BD7E35E061@Ikarus.ameusgmbh.intern> Date: Thu, 30 Oct 2014 02:19:47 -0500 Cc: Alexander Lisachenko , Stas Malyshev , PHP Internals Content-Transfer-Encoding: quoted-printable Message-ID: <51CF9ADE-2E04-4BC0-9E5C-B93498251F59@php.net> References: <544DA1CD.9070109@php.net> <4ED7146272E04A47B986ED49E771E347BD7E35E061@Ikarus.ameusgmbh.intern> To: Christian Stoller X-Mailer: Apple Mail (2.1990.1) Subject: Re: [PHP-DEV] [RFC] Using objects as keys From: willfitch@php.net (Will Fitch) > On Oct 30, 2014, at 2:13 AM, Christian Stoller = wrote: >=20 >=20 > From: Alexander Lisachenko [mailto:lisachenko.it@gmail.com], Sent: = Monday, October 27, 2014 11:18 AM >=20 >> Hello, internals! >>=20 >>> The name __hash is not final, I am open to using __toKey instead or = any >>> reasonable alternative, we may also include a couple of options in = the >>> vote if that will be a point of disagreement. >>=20 >> I like this idea with custom hash implementation because = spl_object_hash() >> is not reliable when objects are quickly created/destroyed, so hashes = can >> be the same for several different objects. However, will it be better = to >> introduce an interface for that? For example, Hashable can be a good = name >> (like Traversable one). Default implementation then can be a simple = trait >> that will be added later to the concrete class. >=20 >=20 > I like the idea introducing an interface for this functionality, = instead > of adding a further magic method. But I think anything like "hash" or > "hashable" is confusing for users. The magic method is more of a PHP approach while an interface would be = more appropriate. That said, this RFC is a true representation of a = hash vs something like spl_object_hash. That=E2=80=99s what causes user = confusion. spl_object_hash would=E2=80=99ve been better served as a = name like spl_object_id or spl_object_hash_id. Something that indicates = uniqueness regardless of the values of a particular object. >=20 > Maybe something like=20 >=20 > interface ArrayKeyConvertable > { > function toArrayKey(); > } >=20 >=20 > Christian