Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79743 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 91771 invoked from network); 16 Dec 2014 20:52:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Dec 2014 20:52:18 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; 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:35633] helo=mail-wi0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0D/F2-08594-08B90945 for ; Tue, 16 Dec 2014 15:52:17 -0500 Received: by mail-wi0-f172.google.com with SMTP id n3so13607299wiv.5 for ; Tue, 16 Dec 2014 12:52:13 -0800 (PST) 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-transfer-encoding:content-type:subject:from:date:to :message-id; bh=BynncfjidLxsoP4/bKC91bb6t9mWo3MfCEUUe5lBCsE=; b=mlLeHHYI174OJ3ZomV7I4w7e4o5bloEzLGgWNZZuZvBKfuZpBWUbHk2vrbQCFmXWiP QFMZqEkPUKCGIJQDiHkGgErWozxKCNxE0etdvTvoMyDqoAdtcsYLCC9B/hiW2Zt+iN/F gqXyFyxvTHOVOBD9xF24QCtoBkMEy+jzW4bKL+3bNzXT2n4WyqF+pyEvEDOBIe8qFQAg ypvGR0PT+OyHiLuWBk/oQzGkQZZDzhMqKIFnAg64k9XU8qXPqtUeRWFo6agWqUKSzlFo FgyHOlWboX6SzetI43lOR/z1nhYgQ1I/5PF7lyxnwm1cUoxw3r6CfoVISIIURVxYPxcP a0GA== X-Received: by 10.194.83.42 with SMTP id n10mr63725236wjy.133.1418763133710; Tue, 16 Dec 2014 12:52:13 -0800 (PST) Received: from [192.168.0.3] (cpc68956-brig15-2-0-cust215.3-3.cable.virginm.net. [82.6.24.216]) by mx.google.com with ESMTPSA id kn5sm2426517wjb.48.2014.12.16.12.52.12 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 16 Dec 2014 12:52:13 -0800 (PST) User-Agent: K-9 Mail for Android In-Reply-To: <54907EDE.6020500@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> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Date: Tue, 16 Dec 2014 20:52:09 +0000 To: Stanislav Malyshev ,internals@lists.php.net Message-ID: <4E4F7392-154C-4282-8D5D-553194D09DCE@gmail.com> Subject: Re: [PHP-DEV] [RFC][VOTE] Objects as Keys From: rowan.collins@gmail.com (Rowan Collins) 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.