Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70294 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 77949 invoked from network); 22 Nov 2013 20:29:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Nov 2013 20:29:39 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@marc-bennewitz.de; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=php@marc-bennewitz.de; sender-id=unknown Received-SPF: error (pb1.pair.com: domain marc-bennewitz.de from 80.237.132.171 cause and error) X-PHP-List-Original-Sender: php@marc-bennewitz.de X-Host-Fingerprint: 80.237.132.171 wp164.webpack.hosteurope.de Received: from [80.237.132.171] ([80.237.132.171:51125] helo=wp164.webpack.hosteurope.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AA/3F-28674-1BEBF825 for ; Fri, 22 Nov 2013 15:29:38 -0500 Received: from dslb-088-072-001-053.pools.arcor-ip.net ([88.72.1.53] helo=[192.168.178.27]); authenticated by wp164.webpack.hosteurope.de running ExIM with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) id 1VjxM6-0004j5-P9; Fri, 22 Nov 2013 21:29:34 +0100 Message-ID: <528FBEAD.4070308@marc-bennewitz.de> Date: Fri, 22 Nov 2013 21:29:33 +0100 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-bounce-key: webpack.hosteurope.de;php@marc-bennewitz.de;1385152178;544d9fda; Subject: Re: [PHP-DEV] Power function as operator From: php@marc-bennewitz.de (Marc Bennewitz) +1 Does it work with https://wiki.php.net/rfc/operator_overloading_gmp ? Am 22.11.2013 17:58, schrieb Tjerk Meesters: > 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! >