Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79766 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 39778 invoked from network); 17 Dec 2014 02:14:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Dec 2014 02:14:18 -0000 Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.177 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.214.177 mail-ob0-f177.google.com Received: from [209.85.214.177] ([209.85.214.177:36745] helo=mail-ob0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A9/82-25720-8F6E0945 for ; Tue, 16 Dec 2014 21:14:17 -0500 Received: by mail-ob0-f177.google.com with SMTP id va2so1595991obc.8 for ; Tue, 16 Dec 2014 18:14:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=FZX/dAAJo32bSXkWTB0/1UNGgdm3DqUb0d+butLtj7o=; b=TtRwrSlUexXAGV3B6Lt683DdnqswKTEN7iv01y9oFCiZ8/qHU/E9P9FCLP3D6rd96b MZkEJVne5Zn0PbS0cA/Ff/sm4OB5bZVPYdUTh/N0WDBY7topRHBds67XKLGmgRu2NT0q Kyaa42DhQUeAV3O4PbqsvqozreF0qhmGTUW6BJAs45FghtiXwMVCgA7UJAT/53amIOZm adNmk7+4+AOt+XouveSmayhkvoAOKjX95ZVeYrVWgTbrZ5CFcoAlPrgLYQY0L8rXo28E mtD/B+X1IxhTEd/PjoWp6IeBhRhnd8lg88MsXZFPoVmRkrLJpWSGaAq6PyJuZHDnXYI1 u4/w== X-Received: by 10.60.158.105 with SMTP id wt9mr15414089oeb.56.1418782453939; Tue, 16 Dec 2014 18:14:13 -0800 (PST) Received: from Stas-Air.local (108-66-6-48.lightspeed.sntcca.sbcglobal.net. [108.66.6.48]) by mx.google.com with ESMTPSA id y15sm1183752oia.20.2014.12.16.18.14.12 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Dec 2014 18:14:13 -0800 (PST) Message-ID: <5490E6F2.4050109@gmail.com> Date: Tue, 16 Dec 2014 18:14:10 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Christoph Becker , "guilhermeblanco@gmail.com" , Rowan Collins CC: PHP internals 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> <5490DC22.2080605@gmx.de> <5490DD19.2080502@gmail.com> <5490E226.3070202@gmx.de> In-Reply-To: <5490E226.3070202@gmx.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC][VOTE] Objects as Keys From: smalyshev@gmail.com (Stanislav Malyshev) Hi! > Yes, but it is already possible to call an object's method in array key > context, so in combination with an appropriate interface the same can be > accomplished. No, it's not possible. It is possible to call object method in an expression, and then use the result of the expression as an array key. But to do that you'd have to check that you're dealing with the object and the call the special method. Looks like you don't understand why PHP has magic methods - since your argument applies to every one of them. Why have __toString if you can just call object method? Why have __call if you could just check if method exists and call a special method if it doesn't? Why have __isset if you could just call special method on an object and pass it the property name? Of course, it's "just sugar". All programming languages are "just sugar" by that definition. > I didn't mean to argue against the RFC, but merely wanted to point out > that one could have object hashes without the proposed magic method > (albeit in a more contrived way). You could have *everything* in a more contrived way. PHP 2 was Turing complete, I am sure. Were we just wasting time these last 15 or so years because everything was done in PHP since then was already possible, albeit "in a more contrived way"? Or maybe there's some value in making the ways significantly less contrived? IMO, that's the whole point of what we're doing here. -- Stas Malyshev smalyshev@gmail.com