Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124082 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 E359B1A009C for ; Sun, 30 Jun 2024 11:05:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719745604; bh=8+0tufggDPnFWOD7fKUnC7UHvt1vuP9p4CFG6dkMkOk=; h=Subject:From:In-Reply-To:Cc:Date:References:To:From; b=h2YEasmLe2l8qCVUry/+/mLdzSIfLGZaYxmXRGeMl009EI4TSx9H2YWYqM0SQc+OW EkSCsqQV4qz4nUvR6y+dqSr5O5d4AM79sDh+Kc3V4rEtEtPANkdVq9tARW5DJqeGVb /h50EAHEZThho2O/n/hPFg8gEdeEWoG75eB3VxKusdw8ees8tqPWHFm2hCyQhyI1Xd QJPcwvLlNM86PcsFNDwj1b9/+EgR2E9Uo6eYfv5v04TdnghIli4fptlqN5q/goXZJR Fop9xS+5I7QlSXDRpzedIhkc1xfKolR8Dev18+6ZDuWIJjAyHgkTuk6zt/20SM6ysH EywHBsqCjVcZg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 22278180057 for ; Sun, 30 Jun 2024 11:06:43 +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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,HTML_MESSAGE, MIME_QP_LONG_LINE,SPF_HELO_NONE,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 mail.sakiot.com (mail.sakiot.com [160.16.227.216]) (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:06:42 +0000 (UTC) Received: from smtpclient.apple (229.152.159.133.rev.vmobile.jp [133.159.152.229]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by mail.sakiot.com (Postfix) with ESMTPSA id 68F17401D3; Sun, 30 Jun 2024 20:05:15 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=sakiot.com; s=default; t=1719745515; bh=8+0tufggDPnFWOD7fKUnC7UHvt1vuP9p4CFG6dkMkOk=; h=Subject:From:In-Reply-To:Cc:Date:References:To:From; b=tfdhoRr+wVEA2ZnRf+UKnG5tyo4tbpiMN4K8oC0Ty1E1DZHj1BC9JlBffDsPKAbpM EQsYKBaExYOaiMjK9OMU6r6PCckhxQZeprZvJKTLduYRdJWRdZXSCTmXaejnUHrn7m ++U/y1nCHsHXSGWzf/w+hfKCehmKFBmN8xxl62hg= Content-Type: multipart/alternative; boundary=Apple-Mail-D0D6DF18-BFEE-4987-852F-9733DBBDA570 Content-Transfer-Encoding: 7bit Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net Mime-Version: 1.0 (1.0) Subject: Re: [PHP-DEV] [RFC] Operator Overrides -- Lite Edition In-Reply-To: <466994ae-64b0-4c73-a841-31de082ed247@app.fastmail.com> Cc: "Gina P. Banyard" , internals@lists.php.net Date: Sun, 30 Jun 2024 20:05:02 +0900 Message-ID: References: <466994ae-64b0-4c73-a841-31de082ed247@app.fastmail.com> To: Rob Landers X-Mailer: iPhone Mail (21F90) From: saki@sakiot.com (Saki Takamachi) --Apple-Mail-D0D6DF18-BFEE-4987-852F-9733DBBDA570 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Hi, >> I'm not sure. Does this mean that such "hack" is unavoidable? >>=20 >> And I don't really understand what "pointless hack" means. This would mak= e sense if operator overloading was already allowed, but it isn't. >=20 > Not unavoidable, but pointless. For example, I attempted to create a Strin= g class that used + for concatenation. This kinda works, but if you pass it t= o something that takes a string, you get the underlying number and not the s= tring you were trying to store. This is because GMP takes over casting forci= ng you to stick to numerical constructs. I don't understand why you only consider the casting case. You can simply co= nvert it to a string via a method. As long as don't use any casting at the e= nd, users can implement it however they like. I don't think this is a pointl= ess hack. Also, allowing "hack" just because they're not useful is not a good idea. Again, if such functionality is provided, it should be exposed as formal sup= port for operator overloading. >> 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, please a= sk! I don't understand why the GMP RFC mentions environments where GMP is not us= ed. There are a few other points worth mentioning, but the existence of polyfill= s makes this especially confusing. > To be usable, the developer must override the desired operations and make t= hem public Is this referring to a polyfill? Or is this just a necessary step to overrid= e the overload? Regards, Saki= --Apple-Mail-D0D6DF18-BFEE-4987-852F-9733DBBDA570 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
Hi,

<= div>I'm not sure. Does this mean that such "hack" is unavoidable?
<= div>
And I don't really understand what "pointless hack" means= . This would make sense if operator overloading was already allowed, but it i= sn't.

Not unavoidable, but pointle= ss. For example, I attempted to create a String class that used + for concat= enation. This kinda works, but if you pass it to something that takes a stri= ng, you get the underlying number and not the string you were trying to stor= e. This is because GMP takes over casting forcing you to stick to numerical c= onstructs.

I don't understand wh= y you only consider the casting case. You can simply convert it to a string v= ia a method. As long as don't use any casting at the end, users can implemen= t it however they like. I don't think this is a pointless hack.
Also, allowing "hack" just because they're not useful is not a g= ood idea.

Again, if such functionality is provided,= it should be exposed as formal support for operator overloading.
=
This is very confusing me. Why does this need t= o be a child class of GMP?

This is= addressed in the current RFC text, if I missed something, please ask!
=

I don't understand why the GMP RFC mentions envi= ronments where GMP is not used.

There are a few oth= er points worth mentioning, but the existence of polyfills makes this especi= ally confusing.

T= o be usable, the developer must override the desired operations and make the= m public

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

Regards,

Saki<= /div>
= --Apple-Mail-D0D6DF18-BFEE-4987-852F-9733DBBDA570--