Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67417 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 49819 invoked from network); 13 May 2013 10:25:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 May 2013 10:25:37 -0000 Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain zend.com from 209.85.212.42 cause and error) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.212.42 mail-vb0-f42.google.com Received: from [209.85.212.42] ([209.85.212.42:60305] helo=mail-vb0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6C/DB-55400-0AFB0915 for ; Mon, 13 May 2013 06:25:37 -0400 Received: by mail-vb0-f42.google.com with SMTP id w16so5076316vbf.15 for ; Mon, 13 May 2013 03:25:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type:x-gm-message-state; bh=AkU43fTdlIPwkXj1NWDA9bro+XoHkkMb/DzAzkG4fjo=; b=oEMXlCI42tqYGEGt/FL1VinMYobClB2REHEuNEhkZTRILKJi7bNm7cbf2M2jINOJK8 jsF+nmUxX0UV6wjUtoSnrsKPo6IsknxuLpfec0+dLpzKW9iYcwFOff5JLUBgjGd2iG2g 9jK9j+KTYEVS9fkWBcjdyooj6Jyw/u5lMGiTrtIVWAeXi7ui5n/wrVoql8aS4zdvO3gt 2jYiwh2qFtD8luY0cCnsWX0cRkP1V9I7QtPjfC+Ijv2Y18rVP24aB2/FX9JbYozIQJZs tLGHNDqRwwZ4r3VpaCE77WfYavJ8LjQRaqL3Ea92290MKV9aBsE0z/Tgr15gMazrC12s Q5rg== MIME-Version: 1.0 X-Received: by 10.52.68.49 with SMTP id s17mr15214456vdt.92.1368440734489; Mon, 13 May 2013 03:25:34 -0700 (PDT) Received: by 10.52.67.235 with HTTP; Mon, 13 May 2013 03:25:34 -0700 (PDT) In-Reply-To: References: Date: Mon, 13 May 2013 14:25:34 +0400 Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: multipart/alternative; boundary=bcaec501625be05fdb04dc96ef88 X-Gm-Message-State: ALoCoQnhUoTX2C7GIBRBEbSZgRFZOxFcXU7xXHOIHxvveDZjmnaSiJsASWXGsoUG+CSQNDNNODQTrXJtKGgK5Ji4cUJvR47+6NhWPVUE9mxTs7Dlccj+s858AS15HfWrJKCVWxFGZU3S Subject: Re: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements From: dmitry@zend.com (Dmitry Stogov) --bcaec501625be05fdb04dc96ef88 Content-Type: text/plain; charset=UTF-8 Hi, On Mon, May 13, 2013 at 1:24 PM, Nikita Popov wrote: > On Mon, May 13, 2013 at 7:49 AM, Dmitry Stogov wrote: > >> Hi Nikita, >> >> The patch looks quite good. >> However, it must slow down each comparison operator (even if it compares >> two integers). >> > In most cases it shouldn't, as the comparisons usually go through the > fast_is_*_functions, which have special handling for integers and doubles. > is_equal_function itself for example is only used in the implementation of > ZEND_CASE (why? shouldn't we use the fast_ one here too?) and stuff like > array_search. > Ahh, you are right :) > > I would suggest overloading of CMP operator instead of separate <, <=, ==, >> !=, >, >=. >> > > But yeah, that sounds like a better solution. The advantages I see: > a) It will automatically work with sorting functions (and other stuff > using compare_function). This is a pretty big plus. > b) You don't have to implement the same (or similar) code for four (or > six) operators. > c) It (at least partially) also solves the concerns raised by Sara. > I'm glad, you are agree :) > Would need an additional object handler though (as compare_objects works > only on objects, so it's currently not possible to support something like > $gmp == 0). > > Or may be we may introduce additional opcode (or even pseudo-opcode) ZEND_CMP to do it in the same way. Also it may be better to use a table of callbacks for each overloaded operand instead of single one that need to do switch anyway. Thanks. Dmitry. > Nikita > --bcaec501625be05fdb04dc96ef88--