Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67667 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10898 invoked from network); 9 Jun 2013 14:34:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Jun 2013 14:34:23 -0000 Authentication-Results: pb1.pair.com header.from=zeev@zend.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=zeev@zend.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain zend.com from 209.85.215.47 cause and error) X-PHP-List-Original-Sender: zeev@zend.com X-Host-Fingerprint: 209.85.215.47 mail-la0-f47.google.com Received: from [209.85.215.47] ([209.85.215.47:34449] helo=mail-la0-f47.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DE/12-30264-E6294B15 for ; Sun, 09 Jun 2013 10:34:22 -0400 Received: by mail-la0-f47.google.com with SMTP id fe20so4906035lab.6 for ; Sun, 09 Jun 2013 07:34:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:references:in-reply-to:mime-version:x-mailer:thread-index:date :message-id:subject:to:cc:content-type:content-transfer-encoding :x-gm-message-state; bh=xaNMwz7r6y0pN0YugEwPjK1VCDl+TtYuHsneru4wm0I=; b=H+tynj4cw0IeTiriRfvXxug5NkQfF23KfQM1Tbmo9hN4MF2WZG++Ly/W8votQznet7 9vqXTD6/umO+m14H5nWLIcbXz0tafhufLjO9wHUYOJXj5wefYjmOTLyQk86w2V1/OWba cOQujeOr5WLJaLzjE9RxcgveDvS8wgf4IrHZKcl0s+E83tdDlDiOUJMqUA8tFUNb8HgO pQg40WdPH5XcPpJhNwhfIgJAcnL5wbeBmq2EoXlZOO6r6QhGQvxT3CU6fFjS2qRlUgfP BZQlr1BzsKBl5W6vaRU0QU9d6oRXMrf4T5Z8BK64aNzfg6z3258q9pBtvxcP5890ddeO wpdA== X-Received: by 10.112.135.99 with SMTP id pr3mr4706128lbb.23.1370788458796; Sun, 09 Jun 2013 07:34:18 -0700 (PDT) References: <056e6e6464af1227f4238a50f562bc29@mail.gmail.com> <9e 7fd04d05a632a38dd306d056eae6e8@mail.gmail.com> In-Reply-To: MIME-Version: 1.0 X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQJbRrTwu75xlJaupAGVjny9GR4KPgIHESCtAXBChYUBvMxDrwEtlwtYArRtSGkCFRs9mQG+KBpdAz9tlb8CCKvR4QEPaE7cAkfUr7MCYWcKaQFKc6R9Amx5N8kBjNbjIwGVXu2Slx2Qt1A= Date: Sun, 9 Jun 2013 17:34:17 +0300 Message-ID: <9f01c72b4a81355bf087d602b21d3d28@mail.gmail.com> To: Nikita Popov Cc: PHP internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQmLjgmfIJvfZlR9EKtOXubJn9/HzeuqydmmBdVxpfbcOEV2aKdSdWnu3k+PRmivjMj+DWHYlp8LcFjxglDRcHAmNkYiedEHmG0IHrw4PxpcqVcLvL4QmOlX/2eN4J+JcUtOeine Subject: RE: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements From: zeev@zend.com (Zeev Suraski) From: Nikita Popov [mailto:nikita.ppv@gmail.com] Sent: Sunday, June 09, 2013 5:15 PM To: Zeev Suraski Cc: PHP internals Subject: Re: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements On Sun, Jun 9, 2013 at 3:37 PM, Zeev Suraski wrote: >> What I meant by cumulativity in that context is really commutativity =E2= =98=BA >> Fixed (and also added transitivity). >> >> In other words, operands that are commutative in PHP (like addition, >> multiplication, etc.) =E2=80=93 one should not overload for domains wher= e they=E2=80=99re >> not commutative. > > Why? Mostly because I don't want us to have to worry about this when implementin= g the engine. It might side effects on optimizations that are valid when dealing with standard values - but not when dealing with these complex values. That said, you brought up a couple of examples where we already have different behaviors for $a+$b and $b+$a, so this point might be moot (mostly referring to the array part, I have a harder time accepting the floating point assertion although I understand why you're saying it...) > That's why I'm not sure it makes sense to have "too strict" definitions > for what is a valid overload and what isn't. I think "limited to cases > where there are clear definitions to > the behavior of all overloaded > operators" and "should be for mathematical use cases only" are enough as > guidelines :) I guess I can live with that (if nobody has any other additional thoughts o= n what we might be missing here). I can say that I mostly heard horror stories about operator overloading from my old C++ days - which is why I want us to do our best to avoid creating the same pitfalls in PHP. I do think that clear extension-level operator overloading support can be quite useful in some cases though (like gmp/bcmath). Zeev