Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123843 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 C08411ADA97 for ; Tue, 25 Jun 2024 20:28:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719347409; bh=VrMyn6OpALepRFyzyCeQwwaVEgMb2cVQFeaXnM8n6eo=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=d8EH4WSh4PAJwwEgI5RW00weJ/3/m8XpGHtzggDnvNZq1wvT7sYFxYsw2dLUPVl4M 2gr8twKd815DVE6F9xEk7wo5fGefbFajFgGHPeHJqy5ZWWtFIZyF53Aj4hSa/cas3w HVPzIt9r/YwIXqzwDM5S0jfPibTco1+Cn3p8lkCGtkXoANZD8xYzwDHGj6w8/NeVQ9 yuCxaPV/rZogJGHd1/1SKGlt+j4iX8YrH6ocyYsBDiZOx9ny0uM63blaNI451u2p+7 wajtVPqgfrxWyxbuHn618srRGBigTs3cHbklgoyEZdJV4Lf1TNl0Lx3iFKO0n83Nmx cEYm0qpLb2GSg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 72B5B180718 for ; Tue, 25 Jun 2024 20:30:07 +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_H3,RCVD_IN_MSPIKE_WL, 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-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (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, 25 Jun 2024 20:30:05 +0000 (UTC) Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-2c8d2c8609eso160360a91.2 for ; Tue, 25 Jun 2024 13:28:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719347327; x=1719952127; 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=VrMyn6OpALepRFyzyCeQwwaVEgMb2cVQFeaXnM8n6eo=; b=dslDORDzk8AzRH0IGC8rFn7HAgrRB3ftIKRj1K9oqyTHEPsAnFDKuTsoA+F0f520zS YtNZ1SSrJP8KlRQ0RsTrKg4ib1NUGkwE9LG9edro2KLUaaSsU2Htb/iIq2puVJM70spU Vy7Fqg6M+ZuhBi9rW+0Zg6IwgH70BnRntm51eYiDVshEZiT9luBSGOO6wGDoaUJFow8O pXKdTG6KbhEBlg+4n+Yx6+iRRAQLVpO9nzZA7a8AcsF1os/jV7k6bZEFIe9YH94PgEig xHFNzcAE+1lx0DcX7Ro15hQ6D0h/g37jWB4COTjCLxEeHHTry1/RIiS3nRhjx/+4sTR4 l+lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719347327; x=1719952127; 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=VrMyn6OpALepRFyzyCeQwwaVEgMb2cVQFeaXnM8n6eo=; b=PVSH75T5OVvzu0l33RHGKxldLkwwezqfXGnplBJQGl7XVU6Cbke0HX4s6PRYQXV+rd E12hxwjYBtIQ/6AJ7FnV6dqEzDjf3YdoPbgk2wPH4q837qJTg7FkKUxhzbB4wdy9BInJ tIhcgAxf94P7jC4jJckQUtrxtARuzgj6BTYmZfr52ibRj3Sy8uDfXYmRdC0hTmBF1eZZ sImKZkmsx6xg4tkWb9ly2HGL3anxJEKbUkq+254a4BvOvm2O9/laCdLhF0571g0CnavQ 7tC+xKk+607gQt1A4EB8YhcxtB8uMI5KocwKrFR/wH2zqZ7xlMMTFRxPv+qLSWAO6YqB pF5w== X-Forwarded-Encrypted: i=1; AJvYcCUsHTVHYTJrWkf+ZNZXp3DO3ougVUh6OgQ90KCjeZ57fb5b5Dy1nags+Yb5XCKEJhnmpUUqO9C8fo4N4TpDVJSOaO1Fyc+emA== X-Gm-Message-State: AOJu0YzqjBhQFeqjbmwGZkJJlYyxLVjnUfyRX1Z5Gnxmy54FcEfNiC0L dGDjau9YSzt6iyPALdwXo9APGHMqfAdkI5XtASGW1AwQ+sdsEOSC8gzWfZQJz6b32JAxZ2qd8v0 VSLnWIxdsJDvP4yixemlEED41zOo= X-Google-Smtp-Source: AGHT+IGbS102FTDBekj1tuEhhD+j51OfnMrlK+9wwA79yPQmHxZ6/MemBFka5vvYDxOmTaokCjuPaNImbPjrVAVXzvA= X-Received: by 2002:a17:90a:be12:b0:2c7:b156:7a8d with SMTP id 98e67ed59e1d1-2c8614891b9mr6174964a91.49.1719347326675; Tue, 25 Jun 2024 13:28:46 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: <190506515d4.f695d014203438.1450648485347018411@barneylaurance.uk> <98CEBD66-4E2C-4CB8-8792-A4AEF9982E41@sakiot.com> In-Reply-To: Date: Tue, 25 Jun 2024 22:28:33 +0200 Message-ID: Subject: Re: [PHP-DEV] Add bcdivmod() to BCMath To: Benjamin Morel Cc: Saki Takamachi , Barney Laurance , php internals Content-Type: multipart/alternative; boundary="000000000000a6f242061bbcbef6" From: ocramius@gmail.com (Marco Pivetta) --000000000000a6f242061bbcbef6 Content-Type: text/plain; charset="UTF-8" Hey Benjamin, On Tue, 25 Jun 2024 at 22:24, Benjamin Morel wrote: > > I predicted this would probably be on the agenda. Another idea is to pass >> arguments by reference, like in `exec()`. >> >> Personally, I find something like a tuple easier to use. However, without >> generics, all we know is that the return type is an array, which may be >> inconvenient in terms of IDE completion, etc. >> > > As for tuple vs reference, I think the general direction is to move away > from references as much as possible, and AFAIK references actually make > things harder for IDEs and static analysis tools, whereas the tuple syntax > array{string, string} is well understood at least by PhpStorm, Psalm and > PHPStan, which can correctly type the function's return value in their > stubs. > Full ack on this. I'm wondering if an array vs an object allocation makes a difference here, or if the amount of `bcdivmod()` execution dwarfs this sort of concern? Thinking: ```php $result = \bcdivmod('123', '2'); echo $result->quotient; // '61' echo $result->remainder; // '1' ``` No idea if that's relevant, so I'm throwing it in the room. Marco Pivetta https://mastodon.social/@ocramius https://ocramius.github.io/ --000000000000a6f242061bbcbef6 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hey Benjamin,

On Tue, 25 Jun 2024 at 22:24= , Benjamin Morel <benjamin.m= orel@gmail.com> wrote:

I predicted this would probably be on = the agenda. Another idea is to pass arguments by reference, like in `exec()= `.

Personally, I find something like a tuple easier to use. However,= without generics, all we know is that the return type is an array, which m= ay be inconvenient in terms of IDE completion, etc.
As for tuple vs reference, I think the general direction is to= move away from references as much as possible, and AFAIK references actual= ly make things harder for IDEs and static analysis tools, whereas the tuple= syntax array{string, string} is well understood at least by PhpStorm, Psal= m and PHPStan, which can correctly type the function's return value in = their stubs.

Full ack on = this.

I'm wondering if an array vs an object a= llocation makes a difference here, or if the amount of `bcdivmod()` executi= on dwarfs this sort of concern?

Thinking:

```php
$result =3D \bcdivmod('123', '= ;2');

echo $result->quotient; // '61= 9;
echo $result->remainder; // '1'
```
=

No idea if that's relevant, so I'm throwing it = in the room.
--000000000000a6f242061bbcbef6--