Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70286 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 52579 invoked from network); 22 Nov 2013 17:14:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Nov 2013 17:14:24 -0000 Authentication-Results: pb1.pair.com smtp.mail=leight@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=leight@gmail.com; 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: leight@gmail.com X-Host-Fingerprint: 209.85.212.172 mail-wi0-f172.google.com Received: from [209.85.212.172] ([209.85.212.172:34086] helo=mail-wi0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 30/1A-28674-EE09F825 for ; Fri, 22 Nov 2013 12:14:23 -0500 Received: by mail-wi0-f172.google.com with SMTP id en1so1048811wid.5 for ; Fri, 22 Nov 2013 09:14:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=ys1gxTmdHjHo8dJvfDfY44pGQZxtoRmjgZQi9Up2e6s=; b=z2LuLezlISJRFonXoa378KIGF9VD0twoooEzefi6WwqDLMF0xWsKmGm4KNj9Fe5bkn SvUrZDRfyWUzmiOvFumowP8dQz/au06mNe7Z44PM3YgfG5adkvNxEEPz7jayB/W1UUXD ArvD6u/cZgS67yGf4S3OD0/Fk6xT9nUb6HehoBlyh7PZKf5tzSzPCmYBqI8o9uf4Nspp coWoA4P0QNlJrIm+9n31FXTJpG4fGTFYjQ9+McQwWRcVWBFPNkyh8jsmCq9uK18bH2gs V4NLn4AlbcJyKrHOJnN3HThpAsKWCISHGmBqOA8FW96MNACpF5DavXbvanCaBbPsD9r2 rA0Q== MIME-Version: 1.0 X-Received: by 10.180.184.14 with SMTP id eq14mr3498948wic.56.1385140459888; Fri, 22 Nov 2013 09:14:19 -0800 (PST) Received: by 10.216.183.68 with HTTP; Fri, 22 Nov 2013 09:14:19 -0800 (PST) In-Reply-To: References: Date: Fri, 22 Nov 2013 17:14:19 +0000 Message-ID: To: Tjerk Meesters Cc: PHP Internals Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] Power function as operator From: leight@gmail.com (Leigh) Definitely something that is missing and would be a welcome addition. Where have you placed it in terms of operator precedence? On 22 November 2013 16:58, Tjerk Meesters wrote: > Hi, > > To challenge myself I had tasked myself to introduce a new operator and > opcode to the language; now that I'm done with it, I wanted to measure the > response on the list to actually get it merged before writing an RFC. > > My work can be found here: > https://github.com/datibbaw/php-src/compare/pow-operator > > It introduces the pow() function as an operator ** (double asterisk), as > can be found in languages such as Python (with perhaps the notable > difference that it's right associative there). > > The logic gets exposed via the ZEND_POW opcode and all the logic that went > into pow() itself is copied into it. The exceptions are that an expression > such as [] ** 2 (squared empty array) will cause a fatal error because the > operands are incompatible, whereas pow([], 2) would give 0. > > Why this operator? Basically because: > 1) it's shorter (the keyboard rejoices). > 2) it's faster (no ZEND_CALL). > 3) it's found in other languages too. > > I've only implemented one of the test suites; there are quite a few for > just one function, but when needed I can add those others as well. > > Btw, changes to vld aren't pushed yet. > > Let me know! > > -- > -- > Tjerk