Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78470 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 70366 invoked from network); 30 Oct 2014 15:06:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Oct 2014 15:06:51 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.172 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.212.172 mail-wi0-f172.google.com Received: from [209.85.212.172] ([209.85.212.172:57280] helo=mail-wi0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F4/37-33916-A0452545 for ; Thu, 30 Oct 2014 10:06:51 -0500 Received: by mail-wi0-f172.google.com with SMTP id bs8so4813248wib.17 for ; Thu, 30 Oct 2014 08:06:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=user-agent:in-reply-to:references:mime-version:content-type :content-transfer-encoding:subject:from:date:to:message-id; bh=d4wtbBEmjC60D+BHmcjpKj4BDgAKslZ+L4JoU4As/ZE=; b=X3//uGfo6O89TJcl4I9wn5oxJ17PZDxN/qpJjxwVd+LPKHXegt5sUfUOLYj5SAg93u lhsa+sYwgLUXyH4iresSTpR52FhBmCwIiVQXS6tQlXSubZ6EiI3YTT6ps2tB1KDB6fwh MVsw/qi3BkAU3zBZwvFIguUR5t8Ocl8g8z/4tZrc5k23n2gfPk+gsTclYKbtXEyHJhpW JK3fdO2E8rj4mYu/BFQwNb2gMHcSIcDHTf7iywdNJcRGttCjUIDYHZK4r483uh7FpkRE 4+NyY66a+r0e6QEhSJYKvRZ9L+Pcx0YHEf5Exw77fZgh9L22dJ4OBu86o3SoqJ+1rXb6 wz6Q== X-Received: by 10.194.172.234 with SMTP id bf10mr21198482wjc.81.1414681601952; Thu, 30 Oct 2014 08:06:41 -0700 (PDT) Received: from [192.168.0.173] ([62.189.198.114]) by mx.google.com with ESMTPSA id gw6sm9318605wib.8.2014.10.30.08.06.40 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 30 Oct 2014 08:06:41 -0700 (PDT) User-Agent: K-9 Mail for Android In-Reply-To: <5452158A.6070003@lsces.co.uk> References: <544DA1CD.9070109@php.net> <4ED7146272E04A47B986ED49E771E347BD7E35E061@Ikarus.ameusgmbh.intern> <51CF9ADE-2E04-4BC0-9E5C-B93498251F59@php.net> <5452158A.6070003@lsces.co.uk> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----ZG1RU4HNPIWSA0N51ZQOEFU8WXEE2G" Content-Transfer-Encoding: 8bit Date: Thu, 30 Oct 2014 15:06:33 +0000 To: internals@lists.php.net Message-ID: <2BB0BBCF-87D2-4E13-9B59-B18A17572B37@gmail.com> Subject: Re: [PHP-DEV] [RFC] Using objects as keys From: rowan.collins@gmail.com (Rowan Collins) ------ZG1RU4HNPIWSA0N51ZQOEFU8WXEE2G Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 On 30 October 2014 10:40:10 GMT, Lester Caine wrote: >On 30/10/14 07:19, Will Fitch wrote: >> 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’s what causes user >confusion. spl_object_hash would’ve 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. > >The bit of the jigsaw I'm still missing here is just what the object of >the exercise is? There are many different use cases for hash keys, and PHP's "array" type is particularly flexible. For instance, de-duplicating a list of items ($foo[$x] = $x), or counting occurrences of each ($foo[$x]++) In the case of a simple DB model, the primary key value is the obvious choice for the hash key, but not all objects are as simple as that. Being able to store the object itself would save having to recreate it from the key, e.g. looking the ID back up for a DB model, or re-parsing UTF8 for a UString. ------ZG1RU4HNPIWSA0N51ZQOEFU8WXEE2G--