Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124083 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 80DF31A009C for ; Sun, 30 Jun 2024 11:15:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719746184; bh=WIJtEKhFb1OY2qeDoFW0xbqJlwDPb7YJn1C8DWpWCK0=; h=In-Reply-To:References:Date:From:To:Cc:Subject:From; b=giqkQR6ZMRXsjCcDlk5hbvy5ow7m1zaAgFW8u0nbhv7xNcrlHmYG7moQupTajE9sM RZS1UDiZtWAyNLzqEaL/+xCogjyaYFjw+aidIjKpP7RFERtGQbz8+0awROqMT1+2em k2nkjc/0atQQDOOSwdVwIgRd7jwrjrLzU8UtzM15+4vjCBpBzuNQwe1w0fpEVOx6ye Pmubp/jFPNxa3oZCvtTHjKAyaC9Q6GdorlQG3w+XIi0NC91I0yJzojZ3fGOtCC+fKx hy7gP9FJ07DRFOYXrBo08lh4KXN5mFcU+KInh8402e9slb4VGVL/9Nzd9u4mBQInkt e3he6jqy7SKmQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0E7C91801E1 for ; Sun, 30 Jun 2024 11:16:23 +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,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from fout2-smtp.messagingengine.com (fout2-smtp.messagingengine.com [103.168.172.145]) (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 ; Sun, 30 Jun 2024 11:16:22 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfout.nyi.internal (Postfix) with ESMTP id 8FC0D13804AE; Sun, 30 Jun 2024 07:15:02 -0400 (EDT) Received: from imap49 ([10.202.2.99]) by compute1.internal (MEProxy); Sun, 30 Jun 2024 07:15:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc: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=fm3; t=1719746102; x= 1719832502; bh=WIJtEKhFb1OY2qeDoFW0xbqJlwDPb7YJn1C8DWpWCK0=; b=b 5N8IVOz6LPiSBSHBeYn8xBc2+yVW2wZmSJgnyaaVjjDOZ+Hii5Z3AKjKsRGWNXTL ZkBdj92oiseepC7nJawM8I5JbH7KtUbnAUACM6bZww7i+pAcoOm47bflR5X73sq0 Z2jjScf5ZgxO9c02/QJED74gcfgH/bqcTajcuzAgyI8hC+pxQGtLQiuHclCGLXup iOcvKN0HUnMq+PDqCZ95KFXR4lv5+BfNi2ffwU3iXQiNMhj9sN8UBPpNGCFh9fSS MThxZyHv5tPfr5PsO6S0m3SZpTGJG0nKFJGvOZC8RR83UpS+8tu9J/q6vx2Zb5yE rsmw2TtpegzgJoFJqacbA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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= fm2; t=1719746102; x=1719832502; bh=WIJtEKhFb1OY2qeDoFW0xbqJlwDP b7YJn1C8DWpWCK0=; b=Shw22zAhJitEXIsX3m4BiNLl9vK+bRJm0AGxBTl3JMFf w9uTCwLAZ54KuztlpxMmsgioat+2h6yX7HnxlpGazUzMsbaHGKk0pSOI//K1J3fG 1HAd/D5HaKdCH5QTgkjBjllM1RTwrb5irnKfuA1qHkuIY04EPlqHdS/DVbodh/0D yiOhmaQw0SbddWFUUbLvCCi5tognGEEzQ/fX/7FT6AKIa31L/rulBpH5GHlTumXD ubJbMjLPzcTZwqUHGzHHjfZRV6Ab+buifDsyZwUkQUdhzNrGdsp6YVdCPsJukWId cPdCWHUx7BR/2OMaWB3pnU11nTFV/DNntct7JNrlpQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddruddugdefjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvvefutgesrgdtreerreerjeenucfhrhhomhepfdftohgs ucfnrghnuggvrhhsfdcuoehrohgssegsohhtthhlvggurdgtohguvghsqeenucggtffrrg htthgvrhhnpedvheekteelveetfeevgeekgfffvdeuhfelveehvdetiefggedtfeejheet gffhueenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hrohgssegsohhtthhlvggurdgtohguvghs X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 1038515A0092; Sun, 30 Jun 2024 07:15:02 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-538-g1508afaa2-fm-20240616.001-g1508afaa Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Message-ID: <257d1b9d-ab54-4538-b044-e89712961598@app.fastmail.com> In-Reply-To: References: <466994ae-64b0-4c73-a841-31de082ed247@app.fastmail.com> Date: Sun, 30 Jun 2024 13:14:40 +0200 To: "Saki Takamachi" Cc: "Gina P. Banyard" , internals@lists.php.net Subject: Re: [PHP-DEV] [RFC] Operator Overrides -- Lite Edition Content-Type: multipart/alternative; boundary=6d17cb8c31734223af877286e13ddf80 From: rob@bottled.codes ("Rob Landers") --6d17cb8c31734223af877286e13ddf80 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable On Sun, Jun 30, 2024, at 13:05, Saki Takamachi wrote: >=20 > Hi, >=20 >>> I'm not sure. Does this mean that such "hack" is unavoidable? >>>=20 >>> And I don't really understand what "pointless hack" means. This woul= d make sense if operator overloading was already allowed, but it isn't. >>=20 >> Not unavoidable, but pointless. For example, I attempted to create a = String class that used + for concatenation. This kinda works, but if you= pass it to something that takes a string, you get the underlying number= and not the string you were trying to store. This is because GMP takes = over casting forcing you to stick to numerical constructs. >=20 > I don't understand why you only consider the casting case. You can sim= ply convert it to a string via a method. As long as don't use any castin= g at the end, users can implement it however they like. I don't think th= is is a pointless hack. >=20 > Also, allowing "hack" just because they're not useful is not a good id= ea. We could just delete php-src, grab a beer, and watch the sunset. I don=E2= =80=99t think you=E2=80=99ll ever be able to stop some programmers from = hacking things together to solve business problems though. I=E2=80=99ve = =E2=80=9Chacked=E2=80=9D weakmaps in userland to make Hour(1) =3D=3D=3D = (yes, there are three! Equals there) Minute(60). >=20 > Again, if such functionality is provided, it should be exposed as form= al support for operator overloading. Thank you for your opinion, this RFC doesn=E2=80=99t stop that from happ= ening and is completely orthogonal. >=20 >>> This is very confusing me. Why does this need to be a child class of= GMP? >>=20 >> This is addressed in the current RFC text, if I missed something, ple= ase ask! >=20 > I don't understand why the GMP RFC mentions environments where GMP is = not used. >=20 > There are a few other points worth mentioning, but the existence of po= lyfills makes this especially confusing. >=20 > > To be usable, the developer must override the desired operations and= make them public >=20 > Is this referring to a polyfill? Or is this just a necessary step to o= verride the overload? I recommend reading up on what a polyfill is, and why they are useful, i= f you are confused. But to answer your question, no, it has nothing to d= o with the polyfill, it=E2=80=99s just a necessary step. The polyfill is= just provided for completeness.=20 >=20 > Regards, >=20 > Saki =E2=80=94 Rob --6d17cb8c31734223af877286e13ddf80 Content-Type: text/html;charset=utf-8 Content-Transfer-Encoding: quoted-printable

=
On Sun, Jun 30, 2024, at 13:05, Saki Takamachi wrote:
=

Hi,
=

I'm not sure. Does = this mean that such "hack" is unavoidable?

= And I don't really understand what "pointless hack" means. This would ma= ke sense if operator overloading was already allowed, but it isn't.
<= /div>

Not unavoidable, but pointless. Fo= r example, I attempted to create a String class that used + for concaten= ation. This kinda works, but if you pass it to something that takes a st= ring, you get the underlying number and not the string you were trying t= o store. This is because GMP takes over casting forcing you to stick to = numerical constructs.

I = don't understand why you only consider the casting case. You can simply = convert it to a string via a method. As long as don't use any casting at= the end, users can implement it however they like. I don't think this i= s a pointless hack.

Also, allowing "hack" j= ust because they're not useful is not a good idea.
=

We could just delete php-src, grab a be= er, and watch the sunset. I don=E2=80=99t think you=E2=80=99ll ever be a= ble to stop some programmers from hacking things together to solve busin= ess problems though. I=E2=80=99ve =E2=80=9Chacked=E2=80=9D weakmaps in u= serland to make Hour(1) =3D=3D=3D (yes, there are three! Equals there) M= inute(60).


Again, i= f such functionality is provided, it should be exposed as formal support= for operator overloading.

Thank you for your opinion, this RFC doesn=E2=80=99t stop that = from happening and is completely orthogonal.


This is very confusing me. Wh= y does this need to be a child class of GMP?
=
This is addressed in the current RFC text, if I missed so= mething, please ask!

I d= on't understand why the GMP RFC mentions environments where GMP is not u= sed.

There are a few other points worth men= tioning, but the existence of polyfills makes this especially confusing.=

To be usable, the developer must override t= he desired operations and make them public

Is this referring to a polyfill? Or is th= is just a necessary step to override the overload?
=

I recommend reading up on what a polyfi= ll is, and why they are useful, if you are confused. But to answer your = question, no, it has nothing to do with the polyfill, it=E2=80=99s just = a necessary step. The polyfill is just provided for completeness. <= /div>


Regards,
=
Saki

=E2=80=94 Rob
--6d17cb8c31734223af877286e13ddf80--