Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123241 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 2577E1A009C for ; Tue, 30 Apr 2024 18:17:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1714501064; bh=vCHkYl+j8qQAh7p6NWYhWVPhuPYhEV98VYcQlujv5E8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Cb/THzQDReMFqLF8rKIMyNp5sdWBDV04lutZFQHf2pasHXMaEBvawVJvYgrxLIdub jNSGiALRpE52zvv4mYnUfX8/TXj5N0nhU4C6ZpiebksBhHV4mejmfOw5QynUFg6EUu hAZX/h7tc0hgA3EAKlMzSkUVohkfJv6CR1JcxjXz5/NlJarT6gM8GgMcs/J9eC5n27 2KjMBEuHnB8e/cqYNglMBBBFaUntjU73XWWfMfewwjY1FqAFB8daZ4mxkHUUxWYjns AFh/NvJnoAz4MflBooOafZQAzyU+sI8pnHaa3SJUJ/qx83QKNKpOa4zi4joG2WGM2y apMVBIZPefrlw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E9B27180612 for ; Tue, 30 Apr 2024 18:17: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,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (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 ; Tue, 30 Apr 2024 18:17:43 +0000 (UTC) Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-51e75e7a267so870111e87.2 for ; Tue, 30 Apr 2024 11:16:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714501018; x=1715105818; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=vCHkYl+j8qQAh7p6NWYhWVPhuPYhEV98VYcQlujv5E8=; b=fcTgxS8Y9pFxq2uEstEx3oe0cGzcqQwZ3qJ9Bxuc6Vg807NAMtd8NxTKgaZwbh6nZ9 8A95yhF5T+2/J5zb75wYEG8RrMear81LOdCn5v2BN2jxfiALifUEm43P2Pq89078tdjX BRiqiBbHyplV9X6uAh3HVth8BXu/j63gVADJAJJV9hovOqv3P2WFLgWU1joteX3lOje0 Nuyx8srza5LcxnUsG/rQlkTh3B2ww0Z8oveU7QvhrbhAO5jFsr6R7PNCvKp9O3gQtrLu 2I9hXXPpvakvRNYQ76dKIIALTI8GFQ8OsfGHX1DsIgoCkBTyZMr6+w6409Nu4Qb/UhZI chcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714501018; x=1715105818; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vCHkYl+j8qQAh7p6NWYhWVPhuPYhEV98VYcQlujv5E8=; b=jaS77709D2ZPPq0tf1obX91++A0CxqjOsbvmNGWmRKkWANab8gHZ02A1NxhOVR6ZaV W4WISMDrR52oJkpJVGMxuVx6LAIkS6Kwd4L0BGyABq4ic+uiyXLtdfnG7u54yqpJQGYY 7ZBD0+L2mI4X0xlxJuut6uPz4KISoJ0dqYHGvB8xBqVZ4tNQajXxiYmLizlPy83enXIA X5miW6AA4tjKFJ2iGSxaAuX7Yltc1p1YpxL4O/XQ2/9/8ukyQaS6CWuERhOUFFyX52d0 rb6xj7p2qyEfCaLbWR7x7zIdP2oAp1+P4h3QAwHptYyrImTRyIoVxs/39VpW+l3pfa3m jJuA== X-Gm-Message-State: AOJu0YzP1IQv4TMomWnqZPeSWtnY3W6dGTeHcw6uohqRGDzcsXhHdccs AFNXHfYeER+vrtDvvbv20qft7j25oQBjoqgDhqCdm4Br49FpFL7F+3+dTQiQagl8ksLNG5OxSHd x6sAXrv3ZapGSeooiHR+2YXqR72dITcTv X-Google-Smtp-Source: AGHT+IE1uzlWhJyKgsSRwt1PHpFBxtU5qThDdHnPDmupT3CjLFtu88dX0LFDICeuFwysXQ1bzyZkC19UtXWG05nd1H0= X-Received: by 2002:a05:6512:534:b0:51b:59d4:deaf with SMTP id o20-20020a056512053400b0051b59d4deafmr160702lfc.33.1714501017374; Tue, 30 Apr 2024 11:16:57 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: <18c42fdbb30.2831.17a3710df6d58f02ca570cc47e197a63@interi.co> <0f64523d-d949-75ed-682b-789fc33fa3b2@php.net> In-Reply-To: Date: Tue, 30 Apr 2024 21:16:20 +0300 Message-ID: Subject: Re: [PHP-DEV] Proposal: Arbitrary precision native scalar type To: "Rowan Tommins [IMSoP]" Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="0000000000001b9af106175460af" From: arvids.godjuks@gmail.com (Arvids Godjuks) --0000000000001b9af106175460af Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, 30 Apr 2024 at 09:19, Rowan Tommins [IMSoP] wrote: > > > On 28 April 2024 07:47:40 GMT-07:00, Robert Landers < > landers.robert@gmail.com> wrote: > > >I'm not so sure this could be implemented as an extension, there just > >isn't the right hooks for it. > > The whole point of my email was that "this" is not one single feature, bu= t > a whole series of them. Some of them can be implemented as an extension > right now; some could be implemented as an extension by adding more hooks > which would also be useful for other extensions; some would need changes = to > the core of the language. > > If the aim is "everything you could possibly want in a decimal type", it > certainly can't be an extension; if the aim is "better support for > decimals", then it possibly can. > > Regards, > Rowan Tommins > [IMSoP] > I think setting some expectations in the proper context is warranted here. 1. Would a native decimal type be good for the language? I would say we probably are not going to find many if any people who would be against it. 2. Is there a need for it? Well, the whole world of e-commerce, accounting and all kinds of business systems that deal with money in PHP world do not leave any room for doubt - https://packagist.org/?query=3Dmoney . The use case is right there :) 3. In most cases people need decimal precision math in the bounds of what the decimal128 standard provides. Most of us just do not want the float drift and while a signed 64-bit integer is big, it has it's limitations and a need for edge layer transformations be it presentation, API endpoints or storing it in the database or other storage mediums. 4. Is it a lot of engine work? Yes, yes it is. Is it worth it? I think yes, especially if we get buying from most of the active maintainers and get a project going for it. This is not going to be the first or last big engine project. But this might warrant a PHP 9 release in the end :) 5. But BCMath/GMP/etc!!! Well, extensions are optional. They are also not as fast and they deal with strings. They are not as fast and you will have to rely on that extension's methods that most math functions are implemented and all that stuff. Frankly, I never had a use case where BCMath was not an overkill. And doing number crunching with BCMath is just slow due to them being strings internally. The use cases are just different. They solve a different problem than a decimal128 does for the language. I think all the discussions on the subject have shown that BCMath RFC is it's own thing and adding a decimal type to the PHP language/engine is it's own thing. They are not mutually exclusive and solve different problems. --=20 Arv=C4=ABds Godjuks +371 26 851 664 arvids.godjuks@gmail.com Telegram: @psihius https://t.me/psihius --0000000000001b9af106175460af Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Tue, 30 Apr 2024 at 09:19, Rowan T= ommins [IMSoP] <imsop.php@rwec.c= o.uk> wrote:


On 28 April 2024 07:47:40 GMT-07:00, Robert Landers <landers.robert@gmail.com>= wrote:

>I'm not so sure this could be implemented as an extension, there ju= st
>isn't the right hooks for it.

The whole point of my email was that "this" is not one single fea= ture, but a whole series of them. Some of them can be implemented as an ext= ension right now; some could be implemented as an extension by adding more = hooks which would also be useful for other extensions; some would need chan= ges to the core of the language.

If the aim is "everything you could possibly want in a decimal type&qu= ot;, it certainly can't be an extension; if the aim is "better sup= port for decimals", then it possibly can.

Regards,
Rowan Tommins
[IMSoP]

I think setting some expectations in the = proper context is warranted here.

1. Would a native deci= mal type be good for the language? I would say we probably are not going to= find many if any people who would be against it.
2. Is there a n= eed for it? Well, the whole world of e-commerce, accounting and all kinds o= f business systems that deal with money in PHP world do not leave any room = for doubt -=C2=A0https://p= ackagist.org/?query=3Dmoney . The use case is right there :)
= 3. In most cases people need decimal precision math in the bounds of what t= he decimal128 standard provides. Most of us just do not want the float drif= t and while a signed 64-bit integer is big, it has it's limitations and= a need for edge layer transformations be it presentation, API endpoints or= storing it in the database or other storage mediums.
4. Is it a = lot of engine work? Yes, yes it is. Is it worth it? I think yes, especially= if we get buying from most of the active maintainers and get a project goi= ng for it. This is not going to be the first or last big engine project. Bu= t this might warrant a PHP 9 release in the end :)
5. But BCMath/= GMP/etc!!! Well, extensions are optional. They are also not as fast and the= y deal with strings. They are not as fast and you will have to rely on that= extension's methods that most math functions are implemented and all t= hat stuff. Frankly, I never had a use case where BCMath was not an overkill= . And doing number crunching with BCMath is just slow due to them being str= ings internally. The use cases are just different. They solve a different p= roblem than a decimal128 does for the language.

I = think all the discussions on the subject have shown that BCMath RFC is it&#= 39;s own thing and adding a decimal type to the PHP language/engine is it&#= 39;s own thing. They are not mutually exclusive and solve different problem= s.

-- =

Arv=C4=ABds Godjuks
+371 26 851 664
=
Telegram: @psihius=C2=A0https://t.me/psihius
--0000000000001b9af106175460af--