Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70322 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45201 invoked from network); 23 Nov 2013 09:02:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Nov 2013 09:02:58 -0000 Authentication-Results: pb1.pair.com smtp.mail=tjerk.meesters@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=tjerk.meesters@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.179 as permitted sender) X-PHP-List-Original-Sender: tjerk.meesters@gmail.com X-Host-Fingerprint: 209.85.220.179 mail-vc0-f179.google.com Received: from [209.85.220.179] ([209.85.220.179:49720] helo=mail-vc0-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CB/50-43422-14F60925 for ; Sat, 23 Nov 2013 04:02:57 -0500 Received: by mail-vc0-f179.google.com with SMTP id ie18so1503589vcb.38 for ; Sat, 23 Nov 2013 01:02:54 -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 :content-type; bh=N+LyX0+De5MLWx2R/a6o2UVhCsxzCFvpRKJWf8/8VWM=; b=k1tDulE9Om6cLVX4hlQkWEUyFWlthQYl1wm1WzY4j6enAoRlbVngFAO+Xs79Djas7j xrbcw42QJ14auccdaHu4AJYNKUd9BODYtDZkZHl2TnQCObMKRI0fQU6NK056t74e+YdY PegxhmMfOs8nDaNz48f//ObazcvuKdLYrzZegpEbZC4mI3Bj4vJgi2pBoXNjNj7pNebK HK1iFGyytnlX5868zrSxnooQ+kWxX2bwa11nvBeid+/qkucDONVDm16IbaclG7sUvKdj 3pnH6dIOwwfTvdqZ+GR4MWkVC4s71ElZdlac2l0wCC+AE0oEwDlYpykKM/VWPSebxmzz CYhg== MIME-Version: 1.0 X-Received: by 10.58.216.74 with SMTP id oo10mr15548330vec.0.1385197374879; Sat, 23 Nov 2013 01:02:54 -0800 (PST) Received: by 10.58.128.33 with HTTP; Sat, 23 Nov 2013 01:02:54 -0800 (PST) In-Reply-To: References: Date: Sat, 23 Nov 2013 17:02:54 +0800 Message-ID: To: PHP Internals Content-Type: multipart/alternative; boundary=047d7b86e3d87941ab04ebd46568 Subject: Re: Power function as operator From: tjerk.meesters@gmail.com (Tjerk Meesters) --047d7b86e3d87941ab04ebd46568 Content-Type: text/plain; charset=ISO-8859-1 Hi again, On Sat, Nov 23, 2013 at 12:58 AM, 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 > So far, there have been no violent objections against the proposal, so I shall go ahead and effect the following: 1) Investigate the GMP overloading option. 2) Write an RFC As for the associativity argument (assuming the precedence is now correct), if not resolved before the voting begins, I would suggest to move that into the vote itself, i.e.: a) don't implement; b) yes, with left associativity; c) yes, with right associativity. -- -- Tjerk --047d7b86e3d87941ab04ebd46568--