Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123225 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 B93071A009C for ; Sun, 28 Apr 2024 14:47:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1714315719; bh=/bfsX7DkkQMXm43Q6S1N+OiL8w4/K4pgTCBVvx4+eMg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=XbQJroB75WyJpoGAINfdVg1UtO7aGAuiWAyIMqOJSzCbXebQeSVgmdZVYN+33Bq8H Vzm8yrfGT8nxBv2RgvxDe2y4CgJsVesOsbLTP08FEKQu6a2KGwxhGPObf24zA3Yfbm xLhwzptlYEuBUQEb9BFpEyaK2I5Fyj3Hl0R0yqiu1P4UnVhoQZO28RVjby9KFa8nBe qP1JrUQq+mRZtGDd50itWAIemGSrM1lPyN6cgbpYNh70TGkvzAeVcRDl6wegV9WMTO EC+Gj/b2QcBTGAX4Nafn0yGYPKFNVt8QaphD2HyKThtnOugCh0bBK6MGWfjxKTGO6I PGE8cskGcsj8A== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 38D75180062 for ; Sun, 28 Apr 2024 14:48:38 +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, 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-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (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, 28 Apr 2024 14:48:37 +0000 (UTC) Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2def8e58471so53890271fa.0 for ; Sun, 28 Apr 2024 07:47:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714315673; x=1714920473; darn=lists.php.net; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=/bfsX7DkkQMXm43Q6S1N+OiL8w4/K4pgTCBVvx4+eMg=; b=dMCCWaaG08XmfgLsMCqjUWgyjuBa1624Fo2oeYHBvVADk0kInhr03mA5uueQ/J/tbX nq0jFc1vJQ50x+pda11DRR77/5uiIrr84MtInDg3nSxbcsEoAWozxdJsV/1ME/n4VP00 4kwPcV48oKs6BX2m/4MJY2p8GGqhmkHxOamtGParTGjlf19Eg8Oqmlqazmb8705Sampz 5Vu2ljxCNLVfaVMcnxo50pSwACZAt108Kz6OdPsZebQiKfb6xhFlgdQ0s6bLPcciS9am FptxlDi3tlRrjV4wulQrAcpFgOftptiD8oRQbb0lZnnZUe40DogJ4ry7LWDed11lrHqn QAug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714315673; x=1714920473; h=content-transfer-encoding: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=/bfsX7DkkQMXm43Q6S1N+OiL8w4/K4pgTCBVvx4+eMg=; b=LJLzZpzzzvxB4yuJKnfI/x5cn7s3WzaQMi4p6yqRaZdBMjr2dNNDIz4F17pCP3oU5d wBTZxccNU9pqC9dW3z4pxl0Mcvh9RkQRSKX4aZaKktKgYGNvAv56QSG3UDGOUrTojIAB biymyhb2JqwvVs7tPtaKhY3hhAIzH0jeOvK11CnfmqFnLSHyjjU0W80rPdk80I5ZY/Vv l2QYCDN7KeuJRRhkmAq/YCyPVH/C/0IypYCe3Ca0tyFaQFzF37VxFW9uqKn4B7CnG9sJ d/BSdFSi6XxJDKZIoiETO3s35v5+0WG5o09Eadzx95HW1fnsxPPO2AIzLu+R78fNmrnq RVBg== X-Gm-Message-State: AOJu0Yw5D0I4leHjb/PZ6qumL8qLEGEoJvIA3fJps3HIMIgjFz5KgYym o4crJsyY2H5JUY1LS//C9Pwu/JRlrgbNc6ew9DhqA1XGMrP6omHN3hvKca0Usj3nwBBwqwPLWVy G8Dco0zjtDlNNn9MSHxY+7B0yQCEP49UhxVQ= X-Google-Smtp-Source: AGHT+IEyiNuMPerpIpQ675WPaFj/p6JDMb45WG4st/RnqwsNRrm5dlDwz3L0CFmV8FALdgqPwktQuMq+wMd9QyjLPY8= X-Received: by 2002:a2e:9d88:0:b0:2dd:da86:ee38 with SMTP id c8-20020a2e9d88000000b002ddda86ee38mr6075002ljj.8.1714315672817; Sun, 28 Apr 2024 07:47:52 -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: Sun, 28 Apr 2024 16:47:40 +0200 Message-ID: Subject: Re: [PHP-DEV] Proposal: Arbitrary precision native scalar type To: "Rowan Tommins [IMSoP]" Cc: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: landers.robert@gmail.com (Robert Landers) On Sun, Apr 28, 2024 at 11:36=E2=80=AFAM Rowan Tommins [IMSoP] wrote: > > > > On 28 April 2024 07:02:22 BST, Alexander Pravdin = wrote: > >Hello everyone. To continue the discussion, I'm suggesting an updated > >version of my proposal. > > > This all sounds very useful ... but it also sounds like several months of= full-time expert development. > > Before you begin, I think it will be really important to define clearly w= hat use cases you are trying to cater for, and who your audience is. Only t= hen can you define a minimum set of requirements and goals. > > It seems to me that the starting point would be an extension with a decim= al type as an object, and implementations for all the operations you want t= o support. You'll probably want to define that more clearly than "anything = in the language which takes a float". > > What might seem like it would be the next step is converting the object t= o a "native type", by adding a new case to the zval struct. Not only would = this require a large amount of work to start with, it would have an ongoing= impact on everyone working with the internals. > > I think a lot of the benefits could actually be delivered without it, and= as separate projects: > > - Optimising the memory performance of the type, using copy-on-write sema= ntics rather than eager cloning. See Gina's recent thread about "data class= es". > > - Overloading existing functions which accept floats with decimal impleme= ntations. Could potentially be done in a similar way to operator overloads = and special interfaces like Countable. > > - Convenient syntax for creating decimal values, such as 0.2d, declare(de= fault_decimal), or having (decimal) casts affecting the tree of operations = below them rather than just the result. This just needs the type to be avai= lable to the compiler, not a new zval type - for instance, anonymous functi= on syntax creates a Closure object. > > There may be other parts I've not mentioned, but hopefully this illustrat= es the idea that "a native decimal type" doesn't have to be one all-or-noth= ing project. > > Regards, > Rowan Tommins > [IMSoP] I'm not so sure this could be implemented as an extension, there just isn't the right hooks for it. Robert Landers Software Engineer Utrecht NL