Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123872 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 74A891A009C for ; Wed, 26 Jun 2024 17:24:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719422744; bh=hHxu6/KI5aM7uj/jdEa60pcqCHMAlyZi25NCsj3qBVY=; h=Date:From:To:Subject:From; b=PRUVfP8H9OE+NnpRzx7toySWzIrXW6dSwjKfSY/rZ+DvGtbld6dI6pS/WbrvvAqna iv37OVrfwzXfbYD3W2lZTK5PigIYaNAIbr+8Y2Dk55wiMID9364Nf+YDvTYCoGQwr3 MYOSdCh690vj0wnICnw10L6elrkPJ1V3XAmfEAjhtj3vJqAqO7GmlEPWFG0sQ4we63 8az06lZ44ws6Nq5w4oPn4YG1CxhGKi67OZkgQbd9+iMDnAXqfEA/Fw1Ac0h5WAWZ3F lUxBFyfzqgPv1iMVRezEoTeHaK/rjsQ1MZn91tutyNl7+eHUrOqlqhFnL3PODf5Mt6 DqgIkO6r+sVIA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D2AD4180B1B for ; Wed, 26 Jun 2024 17:25: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.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 fhigh7-smtp.messagingengine.com (fhigh7-smtp.messagingengine.com [103.168.172.158]) (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, 26 Jun 2024 17:25:43 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 2DDBB114011D for ; Wed, 26 Jun 2024 13:24:25 -0400 (EDT) Received: from imap49 ([10.202.2.99]) by compute1.internal (MEProxy); Wed, 26 Jun 2024 13:24:25 -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 :message-id:mime-version:reply-to:subject:subject:to:to; s=fm3; t=1719422665; x=1719509065; bh=hHxu6/KI5aM7uj/jdEa60pcqCHMAlyZi 25NCsj3qBVY=; b=UfDb4H3RRE9q5NVH9lQ3fKVDFFkb2CffCCxUsKNlWcTJr1qJ SddLBmk8VB4cYil4KNfyi7F1QcWxuprVOcNtOhEkCSKxcLxBmIspgQY2JyDgZQ2j a6DZDkXYiW9018yqjXq6Q4hiALdw+oX4Q86wMU+pV/azJ/BUwDHuWIg3pOSEV/aN TQBpsuNDPKVQ9gTDjeAme5D2y/3r27fQiwD878uyMNrObJJySM/zFXKro+AcWfE1 vqgP151s9gZOd6bmcptsYeSoQ+4ZIgr6gxYXwG5zbOnI9sPvNyLeDPQ3sdQZpDbl WK/J1N/4PpI18/BrnFeHWTeIKHWVQPWOekiJCw== 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:message-id :mime-version:reply-to:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1719422665; x=1719509065; bh=hHxu6/KI5aM7uj/jdEa60pcqCHMAlyZi25N Csj3qBVY=; b=rAmHG9b2LnNvmBC7uwAj2lsy4yR4jLyWMv5O3BeVL4SkeTEwTQh Lx50gVh7oK1ZaC3OPelOTCtFqG+dmtaFw1BCmk5qzCe7if8eVL4J0C0HScTzM0Bw 7Sd5Q1gRT7/GXP3Yob+RuUgekmMD/sDMCT9YTKh9WsnWhjgloitU6dvTwV8Qf2Ha jI/f6I5jyTLY8b2I8zbAhi7eqryRczP2Gn3uwQCGnP4X1y575KlI03jQtKOKFnZo J60NlfzlBr6gnTeuHmMXx0xQgQlolTI/oG+JXUWue5XcEZcC6d7FGG2dEwMu8Ilp P1sfh62Hc3sWb8iUub81KLbGNv2o7uEgTFw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrtddvgdduudefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfffhffvufgtsegrtderre erreejnecuhfhrohhmpedftfhosgcunfgrnhguvghrshdfuceorhhosgessghothhtlhgv ugdrtghouggvsheqnecuggftrfgrthhtvghrnhepvdejieevteefgfdvjeevieetfedtue ffjeekhffgkeffteetgfefveejgeekfeejnecuffhomhgrihhnpehgihhthhhusgdrtgho mhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehroh gssegsohhtthhlvggurdgtohguvghs X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id BA02315A0092; Wed, 26 Jun 2024 13:24:24 -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: <930741fa-eb10-44c6-acbf-34ec9823f8f3@app.fastmail.com> Date: Wed, 26 Jun 2024 19:24:03 +0200 To: internals@lists.php.net Subject: [PHP-DEV] Overriding GMP objects Content-Type: multipart/alternative; boundary=28a11bf822164fdc82872ecdbd4e1116 From: rob@bottled.codes ("Rob Landers") --28a11bf822164fdc82872ecdbd4e1116 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello internals, I've had this little library for a while (https://github.com/withinbored= om/time), mostly as a place to experiment with the quirks of PHP and tak= e it in weird places. Anyway, I've been experimenting with "strongly typ= ed time" in attributes for a while now. At this point, it's a little wei= rd but doable to use something like this: #[MyAttribute(units: StandardSecond, amount: 5)] ... which is less than ideal. What I would really like is this: #[MyAttribute(5 * StandardSecond)] PHP doesn't support operator overloading, which, from the last RFC attem= pt, probably won't for quite a long time. Thus, I started experimenting = with extending the \GMP class, which is perfectly allowed since it isn't= final. For those that don't know, GMP implements operator overloading s= uch that a GMP number times an int results in a new GMP number. Surprisingly, I can get this to work, but I end up with a GMP number -- = with the right value -- but not the right type. Hence this email. In ess= ence, I am attempting to "back-door" my way into having operator overloa= ding. I would like to add static protected methods to the GMP class that are c= alled for operations. In the event all objects are base-GMP objects, no = behavior will change. So, here are my questions: - for built-in extensions, does this need an RFC? - does anyone have any strong opinions against having the ability to hav= e actual, typed units in PHP? - should we revisit operator overloading instead of me hacking my way in= to it? - should we revisit "constant expressions" in attributes? =E2=80=94 Rob --28a11bf822164fdc82872ecdbd4e1116 Content-Type: text/html;charset=utf-8 Content-Transfer-Encoding: quoted-printable
Hello internals= ,

I've had this little library for a while = (https://github.com/withinboredom/time), mostly as a place to exper= iment with the quirks of PHP and take it in weird places. Anyway, I've b= een experimenting with "strongly typed time" in attributes for a while n= ow. At this point, it's a little weird but doable to use something like = this:

#[MyAttribute(units: Stand= ardSecond, amount: 5)]

... which is = less than ideal. What I would really like is this:

#[MyAttribute(5 * StandardSecond)]

PHP doesn't support operator overloading, which, from = the last RFC attempt, probably won't for quite a long time. Thus, I star= ted experimenting with extending the \GMP class, which is perfectly allo= wed since it isn't final. For those that don't know, GMP implements oper= ator overloading such that a GMP number times an int results in a new GM= P number.

Surprisingly, I can get this to w= ork, but I end up with a GMP number -- with the right value -- but not t= he right type. Hence this email. In essence, I am attempting to "back-do= or" my way into having operator overloading.

I would like to add static protected methods to the GMP class that are= called for operations. In the event all objects are base-GMP objects, n= o behavior will change.

So, here are my que= stions:

- for built-in extensions, does thi= s need an RFC?
- does anyone have any strong opinions agai= nst having the ability to have actual, typed units in PHP?
- should we revisit operator overloading instead of me hacking my way i= nto it?
- should we revisit "constant expressions" in attr= ibutes?

=E2=80=94 Rob
--28a11bf822164fdc82872ecdbd4e1116--