Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70784 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 73465 invoked from network); 20 Dec 2013 09:27:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Dec 2013 09:27:37 -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 74.125.82.51 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.51 mail-wg0-f51.google.com Received: from [74.125.82.51] ([74.125.82.51:57788] helo=mail-wg0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D8/61-63357-88D04B25 for ; Fri, 20 Dec 2013 04:27:37 -0500 Received: by mail-wg0-f51.google.com with SMTP id b13so2156029wgh.18 for ; Fri, 20 Dec 2013 01:27:34 -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:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=TI01OGqVHbL/ZghflGtF3EDevdr09IU7UHl4KhWzCEA=; b=n0AeV91uEMucEmnfJOVwX6jGhaVB0NTt4pPJKIVjdBDms3aUsqsCi2XedFeu7rmjW5 jtdp4q1T5bjQnQu2imnZCuNqbrVf1zI2UkhGRSpB05HGbj9QH2pngub9CTjN7YXVXCBU xj5F/VOfOPDbDwvNFdIJfVlQ8PqBm4iBltI17C6MhGOVWvVqB6cdBD7rieuVZxPN33fW mwVOThSisRu9PK1+ifJy7sbJtDr0YzTIQZjcheHVuGs/0eSU6Ts7QbbREKuguXbE+3lV ZpexM4N79Dhwd9+A/P6fL50yBMijiO0u/LpJeREyJ8vtRC9jO0pu80/y9gKzXfYQoBuW tZlw== X-Received: by 10.180.126.38 with SMTP id mv6mr4203191wib.59.1387531653875; Fri, 20 Dec 2013 01:27:33 -0800 (PST) Received: from [192.168.0.149] ([62.189.198.114]) by mx.google.com with ESMTPSA id pk11sm673235wic.8.2013.12.20.01.27.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 20 Dec 2013 01:27:32 -0800 (PST) Message-ID: <52B40D84.7000209@gmail.com> Date: Fri, 20 Dec 2013 09:27:32 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: power operator (again) From: rowan.collins@gmail.com (Rowan Collins) Kris Craig wrote (on 20/12/2013): > But now, let's look at another scenario: > > > $x = -3; // Or $x = -1 * 3, if you wish. > > $y = $x ** 2; > > ?> > > What would be the value of $y under this RFC? That has nothing to do with operator associativity: $x has already been calculated as -3, just as if it were $y = (-3) ** 2 Consider the same thing with mixed addition and multiplication: $y = 1 + 2 * 3; // $y is 7, due to operator precedence $y = (1 + 2) * 3; // $y is 9, due to the brackets $x = 1 + 2; $y = $x * 3; // $x is 3, so $y is 9; operator precedence is irrelevant As I said before, I think people don't always think of "-3" as an operator applied to a literal, but by the same token, they are rather unlikely to write something like "-$x". That limits this whole debate on associativity to those cases where somebody hard-codes a negative value like -3, and doesn't think to add parentheses. Regards, -- Rowan Collins [IMSoP]