Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78483 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4332 invoked from network); 30 Oct 2014 19:51:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Oct 2014 19:51:54 -0000 Authentication-Results: pb1.pair.com smtp.mail=willfitch@fastmail.fm; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=willfitch@fastmail.fm; sender-id=pass Received-SPF: pass (pb1.pair.com: domain fastmail.fm designates 66.111.4.27 as permitted sender) X-PHP-List-Original-Sender: willfitch@fastmail.fm X-Host-Fingerprint: 66.111.4.27 out3-smtp.messagingengine.com Received: from [66.111.4.27] ([66.111.4.27:44462] helo=out3-smtp.messagingengine.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C1/00-04091-9D692545 for ; Thu, 30 Oct 2014 14:51:53 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 68D3721061 for ; Thu, 30 Oct 2014 15:51:50 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute4.internal (MEProxy); Thu, 30 Oct 2014 15:51:50 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.fm; h= x-sasl-enc:content-type:mime-version:subject:from:in-reply-to :date:cc:content-transfer-encoding:message-id:references:to; s= mesmtp; bh=Ot2t9DiiZOVcsxUL8tAn21a3Pwk=; b=D5bXyhr4mpiH8bAFt9Des vBsWKYle/Vc9OPiRY3u4h9T4jO3aQvpum6UxugXDbQZdifrLXF/Uxl2SmbkzIQAj SygkVV98Hz1JhZ+zvxk+13fC+0sWV+0Vh4/FkwwAqygBcW7ao1SyZpBKCzAfKdbO aPLLK0aWvN+ktBiI4Qmhqk= 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=Ot2t9DiiZOVcsxUL8tAn21a 3Pwk=; b=AqUjtw8VB3YbnBZypoPuLjlwpuflE3xjZu9tgKf9/pqhsRoz/oNmYlJ 8BwXLbNhmogP5cw3v3XERrp2LKTF6Aw1+eVK1H5gLltHvpyagNkbenwe308e/9C1 EwRr76EQLrXRauLYuFkLuSUM9/s75tzkyKJ+LbWa/wb46Inmjxms= X-Sasl-enc: +C9jvJ8wBKZ1c75LkjrxBsbRAcOLToe2N06BQQ/C8Wws 1414698710 Received: from [10.90.225.42] (unknown [166.172.56.177]) by mail.messagingengine.com (Postfix) with ESMTPA id 13BD5C00008; Thu, 30 Oct 2014 15:51:50 -0400 (EDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (1.0) X-Mailer: iPhone Mail (12B411) In-Reply-To: <54528445.8080604@sugarcrm.com> Date: Thu, 30 Oct 2014 14:51:49 -0500 Cc: Larry Garfield , "internals@lists.php.net" Content-Transfer-Encoding: quoted-printable Message-ID: <69356D8D-44FB-411F-907D-94B61D4A472A@fastmail.fm> References: <544DA1CD.9070109@php.net> <4ED7146272E04A47B986ED49E771E347BD7E35E061@Ikarus.ameusgmbh.intern> <51CF9ADE-2E04-4BC0-9E5C-B93498251F59@php.net> <54527E7E.2020505@garfieldtech.com> <54528445.8080604@sugarcrm.com> To: Stas Malyshev Subject: Re: [PHP-DEV] [RFC] Using objects as keys From: willfitch@fastmail.fm (Will Fitch) > On Oct 30, 2014, at 1:32 PM, Stas Malyshev wrote:= >=20 > Hi! >=20 >> Put another way, I think a key question here is: >>=20 >> class Foo { >> public $bar; >> } >>=20 >> $a =3D new Foo; >> $a->bar =3D 'baz'; >> $b =3D new Foo; >> $b->bar =3D 'baz'; >>=20 >> $arr[$a] =3D true; >> $arr[$b] =3D true; >>=20 >>=20 >> Does $arr now contain one value or two? >=20 > That depends on the semantics of class Foo. If Foo is something like > UString, then it should contain one value, since UString is a value > object (https://en.wikipedia.org/wiki/Value_object) - or at least it > should be. However, if Foo represents something having separate identity > - i.e. it's a Person class and 'bar' represents name - then of course it > should contain two values, since the name is not the sole source of > Person's identity. So the decision is on you as a programmer. >=20 > And to give you the tool to make this decision and let PHP engine know > about is exactly the point of this RFC. My only concern at this point is the default value of the hash. If we were t= o use spl _object_hash, we could be setting a precedence that a hash must be= unique to each object.=20 Any thoughts on that? >=20 >> If the desire is for it to contain 2, then spl_object_hash($a) already=20= >> has that covered, I think. >>=20 >> If the desire is for it to contain 1, then the proposal sounds like a=20 >> way to normalize Foo::stringifiedValueObjectEquivalent(). >=20 > You can describe it as such, but in a proper standartized way and with > syntax that allows you to use same syntax constructs on all keys and not > have to check each time if it's a special value and call a special > function on it (same purpose as for __toString). > --=20 > Stanislav Malyshev, Software Architect > SugarCRM: http://www.sugarcrm.com/ >=20 > --=20 > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >=20