Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125608 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 889791A00BD for ; Wed, 18 Sep 2024 00:03:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1726617932; bh=yTHW5G345XgutK11QZOh/CfMQj1DpXKoJgzZCb/MSJc=; h=Date:From:To:In-Reply-To:References:Subject:From; b=W9F1NMLU2gjgEdLD7UdT4ZNyAIgR9zhjUJuxDLGHGmiIKZZ1YP8zgdTdKad4nWpBs F4fxWsOOISqKW0h+8ckWeXVG+c8hytWIJDbQSn2eVRxSyW7ufqrVD3pYcYwa+sf0R9 ku68+ZIJSNGohtjKb1ffKo3MuTmVWiyU3pvMqg0iOo3eKLePa1XEoqoPg5Kq072Rbq ISKlnqNTCq7x4LXU4I6xRkGASSfULL5pX9RVt8OVsgj9yZIDa0bgI6F7QK1dT7LIPU +3B1t692uNlyivhtQpeKU+DLvuR7q+R5K2cvzQep1zl/HKY9PMuC7EVaJpGU3tBXxY xzl/uxl9ZW+vw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5A0D718006F for ; Wed, 18 Sep 2024 00:05:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fhigh8-smtp.messagingengine.com (fhigh8-smtp.messagingengine.com [103.168.172.159]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 18 Sep 2024 00:05:30 +0000 (UTC) Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfhigh.phl.internal (Postfix) with ESMTP id AFB7A11400B0; Tue, 17 Sep 2024 20:03:22 -0400 (EDT) Received: from phl-imap-09 ([10.202.2.99]) by phl-compute-01.internal (MEProxy); Tue, 17 Sep 2024 20:03:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1726617802; x=1726704202; bh=yTHW5G345X gutK11QZOh/CfMQj1DpXKoJgzZCb/MSJc=; b=awYfdQ8+Iz9UrwLByW4mYpiuCC mCZ0jC8f7snCs3UN0dQqjPjLo9NVaQ/dc4yl7Er6gF/E8q6898pOYZdfD+Brrf/u UppHfrZciv/3eWp1E08D4i57LL18g7CcglDyJS7RTV7Rfg9Neu8aGLZch5Xd9on4 vHxuMUxcL77A8q/FNNnZHDgJinZx+ClSBEkVV2jiqRkquZELS1yR7LrM4hqsuZIG 5pULAerBQ/L2zvtRVT/sgxKJo8L5/u5vF3G+X4AWsEC/1Zf0AdcfKFteytr6xAcY BQKuVAkks/NSDMxl6RCmnIy3ZgMrBPjQ7QlfdtlaOfotIbjsUQhONFK7TGaA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1726617802; x=1726704202; bh=yTHW5G345XgutK11QZOh/CfMQj1D pXKoJgzZCb/MSJc=; b=Zn+Ez/ubdfZbtCMQ3Yg5Udc/jSwyaQhejQYEY86z73Kl cvaitmbTM47YsgsWUuEJ15iXtMPAMdG4UuZ5GcZxQSwY1PkLOnYGEO3QM2oBI+li mTbq4A9wFDrpdoLy1yTKZmNhyTtgzyNZL1sBi39a8nRlOMTVsidDicibtx7ABJm2 7afMhMtB9at9PUsqhBRq/ofdzDetWnxWE64Ma6AZ/HhDhBkXCoMi/h3bKnD4huxB OC7SvXyawp/4ePorbVaINEFql3Utwa345Jwi4OOUu2w9o1yDDmzwB/1vOqqcD8og okB2pKEdWJDDTOF0VsFEo+XXm5vyFbJJ+JgcB9rKJQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudekkedgvdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnegoufhushhpvggtthffohhmrghinhculdegledmnecujfgurhep ofggfffhvffkjghfufgtsegrtderreertdejnecuhfhrohhmpedftfhosgcunfgrnhguvg hrshdfuceorhhosgessghothhtlhgvugdrtghouggvsheqnecuggftrfgrthhtvghrnhep tdeitddvvdevhfdufffhgeelffetgeffveekheekfeeluedutdeiveekvdetjedvnecuff homhgrihhnpeefvheglhdrohhrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgr mhepmhgrihhlfhhrohhmpehrohgssegsohhtthhlvggurdgtohguvghspdhnsggprhgtph htthhopeefpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehkshgrnhguvhhikhes ughothhsrghnuggslhhosghsrdgtohhmpdhrtghpthhtohepihhnthgvrhhnrghlsheslh hishhtshdrphhhphdrnhgvthdprhgtphhtthhopehmihhkvgesnhgvfigtlhgrrhhithih rdhnvght X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 1E64F780067; Tue, 17 Sep 2024 20:03:22 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Wed, 18 Sep 2024 02:02:52 +0200 To: "K Sandvik" , "Mike Schinkel" , "PHP internals" Message-ID: In-Reply-To: References: <18603813-9ECB-4486-95EE-08BEDECAB88D@newclarity.net> <430bc224-c8b2-4b29-a896-b92a156babcb@gmx.net> Subject: Re: [PHP-DEV] [Pre-RFC Discussion] User Defined Operator Overloads (again) Content-Type: multipart/alternative; boundary=3866981476724152a10eab1b43891551 From: rob@bottled.codes ("Rob Landers") --3866981476724152a10eab1b43891551 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Wed, Sep 18, 2024, at 01:12, K Sandvik wrote: > Operator overloading is indeed a very overloaded topic concerning comp= uter languages.=20 >=20 > But my 0.02 cents is that it's a good thing to have provided it solves= one or more of the problems such as: Hey Kent, > * Will the code be easier to write, maintain, and read? Just imagine being able to ignore the whole DateInterval class. Maybe on= e day we could write $datetime + =E2=80=982 minutes=E2=80=99 and it =E2=80= =9Cjust work=E2=80=9D instead of writing PT2M or using special libraries= .=20 Another example is to consider how most people do time durations in php:= 5 * MINUTE_IN_SECONDS. or something like this. They are usually stored = as integers. If you had a units library of time, you could write 5 * MIN= UTE where MINUTE is a one minute unit object (Which also begs the questi= on of whether operators are =E2=80=9Cconstant expressions=E2=80=9D when = defined=E2=80=A6) so that a unit object is stored instead of an integer,= preventing mistakes or having to dig through the code to find out what = units =E2=80=9C$timeout=E2=80=9D is in. > * Will this help with optimizations? I=E2=80=99m not sure what you mean by this.=20 > * Will this provide new paradigms that are useful for architectural so= lutions? I think it could. For example a Host + Port + Path objects could result = in a URI object. Or a DI container could use it to express service depen= dencies more succinctly.=20 > * or anything else practical and not based on the idea that 'php needs= it as it's available in other languages? >=20 >=20 > --Kent I think it is worth pointing out that you can already do =E2=80=9Coperat= or overloading=E2=80=9D in PHP, so long as your operators are emojis and= you don=E2=80=99t mind how it looks=E2=80=A6 =F0=9F=98=82 https://3v4l.org/gQKTb In all seriousness though, php has classes because other languages have = classes. It=E2=80=99s a valid argument but maybe not a strong one.=20 =E2=80=94 Rob --3866981476724152a10eab1b43891551 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable

=
On Wed, Sep 18, 2024, at 01:12, K Sandvik wrote:
Operator overloadin= g is indeed a very overloaded topic concerning computer languages. =

But my 0.02 cents is that it's a good thin= g to have provided it solves one or more of the problems such as:

Hey Kent,

* Will the code be easier = to write, maintain, and read?

= Just imagine being able to ignore the whole DateInterval class. Maybe on= e day we could write $datetime + =E2=80=982 minutes=E2=80=99 and it =E2=80= =9Cjust work=E2=80=9D instead of writing PT2M or using special libraries= . 

Another example is to consider how = most people do time durations in php: 5 * MINUTE_IN_SECONDS. or somethin= g like this. They are usually stored as integers. If you had a units lib= rary of time, you could write 5 * MINUTE where MINUTE is a one minute un= it object (Which also begs the question of whether operators are =E2=80=9C= constant expressions=E2=80=9D when defined=E2=80=A6) so that a unit obje= ct is stored instead of an integer, preventing mistakes or having to dig= through the code to find out what units =E2=80=9C$timeout=E2=80=9D is i= n.

* Will this help with optimizations?
<= br>
I=E2=80=99m not sure what you mean by this. 

* Will t= his provide new paradigms that are useful for architectural solutions?

I think it could. For example a= Host + Port + Path objects could result in a URI object. Or a DI contai= ner could use it to express service dependencies more succinctly. <= /div>

= * or anything else practical and not based on the idea that 'php needs i= t as it's available in other languages?

--Kent

I think it = is worth pointing out that you can already do =E2=80=9Coperator overload= ing=E2=80=9D in PHP, so long as your operators are emojis and you don=E2= =80=99t mind how it looks=E2=80=A6 =F0=9F=98=82

=
https://3v4l.org/gQKTb

In all seriousness though, php has classes becau= se other languages have classes. It=E2=80=99s a valid argument but maybe= not a strong one. 

=E2=80=94 Rob
--3866981476724152a10eab1b43891551--