Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116631 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 54695 invoked from network); 12 Dec 2021 21:00:39 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 12 Dec 2021 21:00:39 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 65E681804A8 for ; Sun, 12 Dec 2021 14:02:11 -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=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS19151 66.111.4.0/24 X-Spam-Virus: No X-Envelope-From: Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 12 Dec 2021 14:02:10 -0800 (PST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 327685C008C for ; Sun, 12 Dec 2021 17:02:09 -0500 (EST) Received: from imap43 ([10.202.2.93]) by compute6.internal (MEProxy); Sun, 12 Dec 2021 17:02:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=n3HZEVRfOJx5nZ8LJUeJWlBsPR7xoWeCTW53yrm3t o8=; b=A3Wwzbk9UnKZe9lV27PJmv20UPD2o769a7hXvdv2VO5ugrBoDbuhISPx6 UQO320g+w2crbnzNsXPFdGzcr/sajET1WOr0z+ArmNRTuHzylZoKK6+0fFJQ3wwP JKwCnkbDfmqDWiuSHnqPtBO3+zh8yqXjqCdILNc378qIFA3G3r8pta1VrB76wjGa dgPlMXVFgczx3NHS3vwnS7bnkFan/Ti8wwVDVPIdWrRR2YAxyoECB65L9Rvfrl02 NbO90jSeG7ku0Yym3Vxo1i/Y6P1cJPtmznFmrLsYdbU1SUC7WgHjBuwqL/SIMRO6 PJrMSftV0dNtJl2CsON2V9/gYJQgw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrkeeigdduheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgfgsehtqhertderreejnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepffffffejffdugfegvedviedttedvgfejffefffej leefjeetveehgefhhfdvgfelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id E39C6AC03DB; Sun, 12 Dec 2021 17:02:08 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-4514-g2bdc19e04f-fm-20211209.002-g2bdc19e0 Mime-Version: 1.0 Message-ID: <96304dc4-7577-4d4e-a1b2-63e707ea30dd@www.fastmail.com> In-Reply-To: References: <7126a5cb-fdaf-4e50-b8af-7d95965d1125@www.fastmail.com> Date: Sun, 12 Dec 2021 16:01:48 -0600 To: "php internals" Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] User Defined Operator Overloads (v0.6) From: larry@garfieldtech.com ("Larry Garfield") On Sun, Dec 12, 2021, at 12:56 PM, Dan Ackroyd wrote: > On Sat, 11 Dec 2021 at 17:46, Larry Garfield = wrote: >> >> Using symbols, however, would (with some future extension to make it = extensible) allow for: > > I don't get how it's easier, other than being able to skip naming the > symbol name. e.g. adding union and intersection operators > > function __union(...){} > function __intersection(...){} > > vs > > operator =E2=88=AA(...){} > operator =E2=88=A9(...){} > > In fact, I find one of those quite a bit easier to read... If the list of operators is expanded by the engine, yes. The point is t= hat IF it were decided in the future to allow user-space defined operato= rs, that would be considerably easier with a separate keyword. Eg: class Matrix { operator dot(Matrix $other, bool $left) { // ... } } $result =3D $m1 dot $m2; Whether that is something we want to do is another question, but the ope= rator keyword makes that logistically easy, while using __mul or __astri= sk makes it logistically hard. Using an attribute instead to bind a method to an operator, as previousl= y suggested, would also have that flexibility if we ever wanted it. The= re seems to be a lot of backpressure against using attributes for such t= hings, though, and it wouldn't cleanly self-resolve the issue of keyword= s that make sense on methods being nonsensical on operators. (public, s= tatic, etc.). I'd probably be fine with it myself, but I cannot speak f= or others. --Larry Garfield