Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108622 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 61653 invoked from network); 16 Feb 2020 15:58:20 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 16 Feb 2020 15:58:20 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E93C11804D1 for ; Sun, 16 Feb 2020 06:13:27 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS8560 212.227.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 16 Feb 2020 06:13:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1581862404; bh=mZe0AjTHiUu2i4bWR4GU3e39paxZ9nwEpWdQ8sqzHZ4=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=UFwGlIok7rQOshkxlnUGFlI5d4iZNUvqXlTrD0XF++cQRqAKPirK/SVWAYxfHY6EX JP+d5gjZMS2nkQc+Mr0gbpWVlgQ4+jRHPUBgmMV1JcG3vRlcZIkRy+kPx8BgCmBw/M MStNYVnrECISP8ao7YL/k5A3uCFH+TJryYJF1NnU= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from DESKTOPF2PTDOD ([141.35.40.65]) by mail.gmx.com (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1Mk0Ne-1jjIGy0YsC-00kRzS; Sun, 16 Feb 2020 15:13:24 +0100 To: Cc: "'PHP internals'" Date: Sun, 16 Feb 2020 15:13:23 +0100 Message-ID: <005b01d5e4d3$4015caa0$c0415fe0$@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 Thread-Index: AdXkzLyF6WXN/lQwRjS+jmP6kEbCYw== Content-Language: de X-Provags-ID: V03:K1:62YPkwD0Jb/m5JmYEP04qECGEp/GHJM3ebwI4AFakwYLQvpo3JN 5ukt23yj6elAKUTg1g8z4KHBCA5rLebUsUwCmlSX2H7lWsb2KHTIdSfUGm6CJHyg3+5kcuE J29PxSdoIrZtZ4LoVV6EYr3qlr9CjtoIWvvH+U3/gg/y1S/UMKzYXQN3e2zmsiK91r/8xVt PIooXH0KZsU29KcjZ9f9Q== X-UI-Out-Filterresults: notjunk:1;V03:K0:DGjG3tIR0ws=:EYemi0sQux5r7pcemZNarN sheleaBo1oPLMu9LJbK6VthdZaBvlT5aSMHbd00me6d8ELRXuHuZ0DY9WFVGyZCM01KWCXDsi ioFps4Hxt9Ogn6hvj/PwFITKmh3KT3Pe4s9WXaqGk1yxBewlBN21gIMYBZiagDA2B75SHsB0V 4YM6qeM8l4dceyy3xeV/XzKWFxiHS1KupDpR4uEpcR69z13H3MrVP6EtA1QguvD4IvcbBkOrU EP2UscJ3/kVyha/hHUFHkErVJpuVZSnf6KWh2OOwbeilQBjEoFILtQynCGbJEnujLAV1+rJ7B 8RT4Wv/8aqzU72vaPkKUxHQbDOrnLZJEgc35+4subkpZHdvcm6o7teYG/isxeP03cK24kBAbe 5ec9l70Vm6ERcrE8CDYihXfk/LHYpITX3XbZppdn0lEpQ1uwCLgF4pQ2xZb+iFEz0tF+qqOzm SGg2H7nyKzTZif9sGLNA+7BBpp5Fosc7YqS1CjptqL/e5g5qSoo7dfszR++2WwIhu5wTe+HnM syeUy2/x9GhLsclQkTj9O/fwrZikYm0MHAehM7aK31RR4LulTWoN/vFFi6u2YXAh5BnXEvcsP JZrL9b5gvS8flBWCrnu9xVxUcH1fHucFXbf3j0XIKKrwmFMzWrqKeYmSlqpCC7zqENAxx+Jff dPfe8SOtNjkGtpE+CwQd7WWIYkrMwYYLOOfgUV8/QuVe7GIgudMCD0vgQqzQwLs7KImugWYTo F2hG6dCrWSm5uAzhHaR31Zr+wbHGHvMVi3z1UE3yBlJbhBE+C7sB+TGKLqrkdzL0cZatIdN4M +7yqzRdggAWQ/4bAGZzF6kaVIQ3GGmIpJ4qu0OsSRj8jJkx+AbOLprczyICbF+TlW4N4JJTYc tYQW4/qYikvokcX2Y4CVy2gIlr8wKGC8ElL0pEe0E3U5KKIr9reMor0kc87jSClnng/Wz3ftb q7G748TyjWgGSuWAP2ee8MI9pYkBTpnJlekNwh1pYwXeeEfzHYQ2XKwRod03vuMOy8YDrhNXP NkmYKqeOZYJez+U17kvA/kRWjnTtCf8RJ0NdWHn2hRYxV7UEA0XmCCd45LOwLf2hHPcjHO8nb IpkJS308Vfwckfwc7AAtLBLAge+ew8qgQLpLPgTNiU6WDUuHZoSOfZnSixuHN1O/Qhw+sUxHW mJ6Hio2CnMx6+Y5iYUw+mN5Unpnbta1k9GXJ8IAa9FBeC0du0GuwGaZhIi+mT3KhmrM1fzjvZ YVAele9Hy4kezijvs Subject: Re: [PHP-DEV] [RFC] Userspace operator overloading From: jan.h.boehmer@gmx.de > ) I know you're not alone in that feeling. If it turns out this is the majority view, I think it answers a couple of open questions: > > Overload methods should definitely be named after operations, not = symbols, to remind people they are implementing addition, not giving new meaning = to + >=20 > They should probably be grouped into interfaces, which this RFC has so = far resisted. How often does it make sense for a type to support addition = but not subtraction, or multiplication but not division? Even more clearly, = if a type claims to implement bitwise OR but not bitwise AND, NOT, and XOR, something is =20 > definitely fishy. > > You can't stop people using overloading DSL-style, but you can make it obvious that it's not the intention of the feature (if we agree that = it's not the intention; maybe some people here are really hoping to use it = that way?) On 16/02/2020 10:31, rowan.collins@gmail.com wrote: Except for simple numbers, almost no mathematical objects define = division (only some special matrices can be on the right hand of a division, and = for vectors there is no definition for division at all). Also think of time differences: $datetime1 - $datetime2 results in a DateInterval, but $datetime1 + $datetime2 is not a meaningful operation (Datetime already = has a diff() method that do this). Also it is not really possible to split multiplicative and additive = methods into different behavior, as when $a implements Additive Behavior it = should be possible to do an -$a, but because of the the way PHP compiles the = code this becomes -1*$a. This is sufficient for almost all cases, but it = would require that the code also provides an possibility to handle = multiplication. In my opinion this would lead to that even if an object implements these interfaces, in many cases you cannot be sure that it really supports all operations, which would contradict the whole idea of defining = interfaces. I wonder if it would be reasonable to allow voting between an interface approach and the "separate magic function for each operator" approach... Greetings, Jan B=F6hmer