Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79760 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26310 invoked from network); 17 Dec 2014 00:55:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Dec 2014 00:55:13 -0000 Authentication-Results: pb1.pair.com header.from=guilhermeblanco@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=guilhermeblanco@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.181 as permitted sender) X-PHP-List-Original-Sender: guilhermeblanco@gmail.com X-Host-Fingerprint: 209.85.213.181 mail-ig0-f181.google.com Received: from [209.85.213.181] ([209.85.213.181:46693] helo=mail-ig0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F3/00-25720-B64D0945 for ; Tue, 16 Dec 2014 19:55:12 -0500 Received: by mail-ig0-f181.google.com with SMTP id l13so8690287iga.2 for ; Tue, 16 Dec 2014 16:55:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=a44gblr2GVhzLmjRhZMGrf2KKsEOlID+HE6qOfej9yE=; b=tIms1JK96noprAL8HGTLAerXiu5BuDp45te4UYzwBnk3H9Nt92r0AvuVxH50hAf7B9 IVSU9ooD2ZNAgbQww0pj+IVGJcCOsOj/pEOw2NrNvIPBMd3uhw5hHaHWC/MqFOQCqu7b VDsIx8KCIUwNpnPbOu9M+ExJMGi5kkgD6u7ploNkJ7GWbfAufFxMoSgcWKKKGfKw5ExG /ivYGt9egjqPcpvXH+KOfTiuGqS3vjkSa5G/Aek2LhKx47lZ5HnuET4T7vEqCbOYIgv8 Rh7POiCWJ95uLLpaYkrbQ0yEi4Y7mEQ+qGU2hrnf0w6C60x0EOhzjTiZXfsw7we+K122 Akhg== X-Received: by 10.43.129.196 with SMTP id hj4mr35706526icc.21.1418777353301; Tue, 16 Dec 2014 16:49:13 -0800 (PST) MIME-Version: 1.0 Received: by 10.64.238.75 with HTTP; Tue, 16 Dec 2014 16:48:52 -0800 (PST) In-Reply-To: <4E4F7392-154C-4282-8D5D-553194D09DCE@gmail.com> References: <548FEE87.7020602@gmail.com> <549009EE.7040808@fischer.name> <54907683.2070509@gmail.com> <8AB6896C-D5DB-4471-BBD5-60784B2FC1BE@gmail.com> <54907EDE.6020500@gmail.com> <4E4F7392-154C-4282-8D5D-553194D09DCE@gmail.com> Date: Tue, 16 Dec 2014 22:48:52 -0200 Message-ID: To: Rowan Collins Cc: Stanislav Malyshev , PHP internals Content-Type: multipart/alternative; boundary=001a11c1fa9828c8ac050a5ed8c0 Subject: Re: [PHP-DEV] [RFC][VOTE] Objects as Keys From: guilhermeblanco@gmail.com ("guilhermeblanco@gmail.com") --001a11c1fa9828c8ac050a5ed8c0 Content-Type: text/plain; charset=UTF-8 > On Tue, Dec 16, 2014 at 9:39 AM, Matteo Beccati wrote:Hi Guilherme, > >> On 16/12/2014 12:34, Guilherme Blanco wrote: >> Hi, >> All I can say is that the lack of this feature is one of the main reasons why Doctrine doesn't fully work with composite keys. >> With this enhancement it would now become possible to implement a proper IdentityMap. > >Are you sure you haven't misinterpreted the RFC? Hi Matteo, I did not. You may think I mentioned IdentityMap as entity map, but I'm talking about entityPersister mapping or resultPointers consumptions that happens inside Doctrine throughout the execution. Entity IdentityMap is enough to use purely spl_object_hash(). We should focus on the main goal here, which is complex structures as keys. As a very complex library developer I do see lots of use cases for this. []s, On Tue, Dec 16, 2014 at 6:52 PM, Rowan Collins wrote: > > On 16 December 2014 18:50:06 GMT, Stanislav Malyshev > wrote: > >Hi! > > > >> Explicit conversion is trivial, just call whatever method you like. > >> Sure, you can't write (int)$obj, but $obj->toInt() is just as > >> expressive. > > > >Exactly the same applies to __toString and whole ArrayAccess, yet we > >still have them. Avoiding boilerplate code helps. Especially if > >boilterplate code would look like: > > > >if(is_object($foo)) { > > $foo_key = $foo->toInt(); > >} else { > > $foo_key = $foo; > >} > >$a[$foo] = 1; > > > >Doing it each time is annoying. > > I was just confused by your statement that "explicit conversion is > inacessible from userspace". But yeah, I guess with string keys you can > just write $a[(string)$foo] and assume/hope it will do something meaningful > whatever the type of $foo. > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Guilherme Blanco MSN: guilhermeblanco@hotmail.com GTalk: guilhermeblanco Toronto - ON/Canada --001a11c1fa9828c8ac050a5ed8c0--