Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67666 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 7621 invoked from network); 9 Jun 2013 14:15:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Jun 2013 14:15:22 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.171 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.214.171 mail-ob0-f171.google.com Received: from [209.85.214.171] ([209.85.214.171:36839] helo=mail-ob0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 97/71-30264-9FD84B15 for ; Sun, 09 Jun 2013 10:15:22 -0400 Received: by mail-ob0-f171.google.com with SMTP id dn14so8869498obc.30 for ; Sun, 09 Jun 2013 07:15:19 -0700 (PDT) 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=w8pg/pgQaiJtEmMQPSEpFz4HNcobpo0gIb1UB9Ih8aU=; b=bbDrWWBMp8mQrvU4kSzfZ+1HfZ6PzhJfMGzjmxDGNnzeTaexvFPjPi6kINMV1YMq4d 7LeIL0PtcO32uwYo5VxehrozH1AmZQwrOoLdRn8GqD2XaJqoYiE0HcNx7U37pLPD/NCD xP6V8YWn0MErn0TZZ+vZRSorDajqmuDWqLq2HNx7ybWDRTVZZ1eYLUhrzs8s/KdXhk/2 ebGDuKGXbnfU4SS8TprgxyBIomzUS66WNb86zUS59LvZAzR1j9/kmn/iRAv+b0k2FjGX pwking3PpTVO+XC0GGBk38V1gncklKsfvNyt/fYvdmSYpmhVT3mw0cEH7kyIIKWF+NH6 ZLgg== MIME-Version: 1.0 X-Received: by 10.182.214.39 with SMTP id nx7mr5087293obc.20.1370787319336; Sun, 09 Jun 2013 07:15:19 -0700 (PDT) Received: by 10.182.97.228 with HTTP; Sun, 9 Jun 2013 07:15:19 -0700 (PDT) In-Reply-To: <9e7fd04d05a632a38dd306d056eae6e8@mail.gmail.com> References: <056e6e6464af1227f4238a50f562bc29@mail.gmail.com> <9e7fd04d05a632a38dd306d056eae6e8@mail.gmail.com> Date: Sun, 9 Jun 2013 16:15:19 +0200 Message-ID: To: Zeev Suraski Cc: PHP internals Content-Type: multipart/alternative; boundary=e89a8ff1c02a3b580504deb94bd4 Subject: Re: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements From: nikita.ppv@gmail.com (Nikita Popov) --e89a8ff1c02a3b580504deb94bd4 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On Sun, Jun 9, 2013 at 3:37 PM, Zeev Suraski wrote: > What I meant by cumulativity in that context is really commutativity J > Fixed (and also added transitivity). > > > > In other words, operands that are commutative in PHP (like addition, > multiplication, etc.) =96 one should not overload for domains where they= =92re > not commutative. > > > > Zeev > Why? For example matrix multiplication is not commutative, but I would still consider writing $matrixA * $matrixB a valid application of overloading. Non-commutative multiplication operations aren't uncommon (that's why a mathematical ring only requires the addition operator to be commutative). The same also applies the other way around: For example PHP's default + operator is *not* commutative (when used on arrays) and both + and * are non-associative and non-distributive (floating point arithmetic), but you'd probably still expect those properties from an overloaded +/- operator. 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 :) Thanks, Nikita --e89a8ff1c02a3b580504deb94bd4--