Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70344 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16061 invoked from network); 24 Nov 2013 05:47:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Nov 2013 05:47:08 -0000 Authentication-Results: pb1.pair.com header.from=ww.galen@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ww.galen@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.50 as permitted sender) X-PHP-List-Original-Sender: ww.galen@gmail.com X-Host-Fingerprint: 74.125.82.50 mail-wg0-f50.google.com Received: from [74.125.82.50] ([74.125.82.50:43820] helo=mail-wg0-f50.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4A/D0-10115-BD291925 for ; Sun, 24 Nov 2013 00:47:07 -0500 Received: by mail-wg0-f50.google.com with SMTP id a1so772948wgh.5 for ; Sat, 23 Nov 2013 21:47: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 :content-type; bh=Vye4117PuBraFilvIvqzAlM4Fofit/YmmLq9/c1QNo0=; b=y6QQcPcIpfeIVpXsuRvpm9QjyXXTI6i22xYO1CJFyyavhdJ/Cl9ed0jzqSBquB1ICd 4StlRLQMLwIbBFZW1FKFbqvUgRPM7h84d/xEUPf6UXISSarJzRjHXdTPPEAYNTfMwrOM HKJFzcmjEu8rKnLYTZD5aMwYvZu7PdUEy7g2uLiCHhexpNAByk/NquJwaLfeotFjWcye LS5ytTyM/LmE0+nUHVrsSvqatMrLKeoV77xLuqfEm1HymsdYP9zNyHZ2iRD6BqoJSPVi 3PEftloj+XYKy4Bv+JOHnr75u9d7WuyfRyvRbBfaC3ve/kcCFni5AAk6eyO6YCbXCje0 ROLQ== X-Received: by 10.194.174.36 with SMTP id bp4mr16510993wjc.7.1385272024024; Sat, 23 Nov 2013 21:47:04 -0800 (PST) MIME-Version: 1.0 Received: by 10.216.209.201 with HTTP; Sat, 23 Nov 2013 21:46:23 -0800 (PST) In-Reply-To: References: Date: Sat, 23 Nov 2013 21:46:23 -0800 Message-ID: To: PHP internals list Content-Type: multipart/related; boundary=089e0141a0aee8ebca04ebe5c6dd Subject: Re: [PHP-DEV] rfc: pow-operator From: ww.galen@gmail.com (Galen Wright-Watson) --089e0141a0aee8ebca04ebe5c6dd Content-Type: multipart/alternative; boundary=089e0141a0aee8ebc704ebe5c6dc --089e0141a0aee8ebc704ebe5c6dc Content-Type: text/plain; charset=ISO-8859-1 On the left-vs-right-vs-non-associative debate: it seems to me that the reason for supporting associativity for any binary operator is to cut down on the number of parentheses that must be typed, which can help cut down on visual clutter. Otherwise, you might as well use a Lisp. (What are other reasons?) If that's true, then whether to pick left or right association should depend on the most common use-case. Personally, I'd be much more likely to mean 2**(3**2), as (2**3)**2 is equivalent to 2 ** (3*2) but is less performant. Also, by making ** right-associative, 2**3**2 is visually more distinct from 2 ** (3*2); if left-associative, 2 ** (3 ** 2) and 2 ** (3*2) would be more easily confused when reading or writing. Closely related to the power-tower argument is the relation between associativity and hyper operations, which offers another reason why right association is more natural in mathematics. Defining hyper operations in terms of hypo operations (successor -> addition -> multiplication -> exponentiation -> tetration ...) requires right associativity. However, as addition and multiplication are associative (and the computational versions of these operations aren't usually implemented in terms of each other), it doesn't much matter whether they're made left- or right-associative. For reasons others have stated in this conversation, computational + and * are generally implemented as left-associative. Mathematical exponentiation isn't associative (hence this whole debate), so the reasons for allowing a switch from right- to left- association simply isn't present. Of course, the computational operators aren't the same as the mathematical, so this isn't actually a rigorous argument in favor of right association. Finally, here's a graphic depicting the "exponentiation is right-associative in math" argument (sorry text-readers, you'll have to go to http://i.imgur.com/G9aIn6X.png if you want to see the image): [image: Inline image 2] Of course, this doesn't help at all to determine whether ** should be associative or not. --089e0141a0aee8ebc704ebe5c6dc Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On the left-vs-right-vs-non-ass= ociative debate: it seems to me that the reason for supporting associativit= y for any binary operator is to cut down on the number of parentheses that = must be typed, which can help cut down on visual clutter. Otherwise, you mi= ght as well use a Lisp. (What are other reasons?) If that's true, then = whether to pick left or right association should depend on the most common = use-case.

Personally,= I'd be much more likely to mean 2**(3**2), as (2**3)**2 is equivalent = to 2 ** (3*2) but is less performant. Also, by making ** right-associative,= 2**3**2 is visually more distinct from 2 ** (3*2); if left-associative, 2 = ** (3 ** 2) and 2 ** (3*2) would be more easily confused when reading or wr= iting.


3D"Inli=

Of course, this doesn't help at all to determine whether ** = should be associative or not.
--089e0141a0aee8ebc704ebe5c6dc-- --089e0141a0aee8ebca04ebe5c6dd--