Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:90017 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4580 invoked from network); 4 Jan 2016 23:26:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Jan 2016 23:26:49 -0000 Authentication-Results: pb1.pair.com smtp.mail=bobwei9@hotmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=bobwei9@hotmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain hotmail.com designates 65.55.111.81 as permitted sender) X-PHP-List-Original-Sender: bobwei9@hotmail.com X-Host-Fingerprint: 65.55.111.81 blu004-omc2s6.hotmail.com Received: from [65.55.111.81] ([65.55.111.81:59216] helo=BLU004-OMC2S6.hotmail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1A/61-07292-7BFFA865 for ; Mon, 04 Jan 2016 18:26:48 -0500 Received: from BLU436-SMTP36 ([65.55.111.71]) by BLU004-OMC2S6.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.23008); Mon, 4 Jan 2016 15:26:44 -0800 X-TMN: [5vkuoDQzSgrrbtHaQuRh2UFk+aL+2RrE] X-Originating-Email: [bobwei9@hotmail.com] Message-ID: Content-Type: multipart/alternative; boundary="Apple-Mail=_8B638AD7-FEED-46BD-AA06-698FBB43D4FD" MIME-Version: 1.0 (Mac OS X Mail 8.2 \(2070.6\)) In-Reply-To: <1451936344.323.14.camel@kuechenschabe> Date: Tue, 5 Jan 2016 00:26:30 +0100 CC: Sara Golemon , PHP internals References: <1451936344.323.14.camel@kuechenschabe> To: =?utf-8?Q?Johannes_Schl=C3=BCter?= X-Mailer: Apple Mail (2.2070.6) X-OriginalArrivalTime: 04 Jan 2016 23:26:42.0542 (UTC) FILETIME=[5E9358E0:01D14747] Subject: Re: [PHP-DEV] RFC Operator Overloading in Userspace From: bobwei9@hotmail.com (Bob Weinand) --Apple-Mail=_8B638AD7-FEED-46BD-AA06-698FBB43D4FD Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" > Am 4.1.2016 um 20:39 schrieb Johannes Schl=C3=BCter = : >=20 > On Sat, 2016-01-02 at 18:14 -0800, Sara Golemon wrote: >> https://wiki.php.net/rfc/operator-overloading >=20 > Back in the days when I created the first implementation of operator > overloading in the engine[1] I didn't see it fit for the language. > Meanwhile we have more type hints and stuff making it a bit less = magic. > I still don't think this approach is really good. for instance we = loose > associativity; taking the Complex example: >=20 > $a =3D new Complex(1, 2); > $b =3D 3; > echo $a + $b; // works > echo $b + $a; // will error out > ?> >=20 > Of course this can easily be fixed by looking at the order, at least = in > this simple case. In a more complex example where a function might > return an integer, double or complex number this becomes more > complicated. >=20 > For this to work we'd need non-member functions to do this and we need > function overloading ... >=20 > I believe we'll only get a half-baked solution and I prefer the = current > state over half-baked. >=20 > johannes >=20 > [1] http://news.php.net/php.internals/14558 Then that must be very long ago, as, looking at code even as old as 5.6, = http://lxr.php.net/xref/PHP_5_6/Zend/zend_operators.h#959 = clearly = checks both operand for object with custom do_operation. The only issue is when you try to compare two objects with each custom = operation handlers, like, e.g. an instance of Complex and Fractional. To = have that working, we couldn=E2=80=99t just use real fractionals, but = would need a special ComplexFractional, as Fractional may not be aware = of Complex. This really is the limit of this abstraction=E2=80=A6 But I guess, it = won=E2=80=99t be too much of an issue in real world. Bob= --Apple-Mail=_8B638AD7-FEED-46BD-AA06-698FBB43D4FD--