Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124334 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 3FDC71A00B7 for ; Wed, 10 Jul 2024 08:55:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1720601792; bh=R6l8svw4jcAgoi+/2oSqNG0wKyFGZKmfaPcGu/ayNm8=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=eYAI7YTSISO1T+LQ9/W7tii6CdlDQWKeZMwcXNsZ+SpRlMfkrsvRV6dux9jjeFu1E 3SINjpQ+NCS/iQawSwtge74M8HLRbJFj5GI7L1bI2lavkc5ClaAnPMJvsPUx0nbAXQ YtmNgrbopmshJQdHk6+ZOVh4+3uOC55MwBzmCDlaLnrjnoDsbpGF2yPOKnYMkIFIQ/ Dbp+VlHE7fYUDQuxbtABjRY2I+TPydByxr3mLHrrMS/HPBNqWW6/8AI3HyeAsdtvXV olR95DxUm51h9W0TjYALHuVk47kFnN0eR8u6PGMlbT4A7LudZvaGieAGKOUCF61nYL UJGT8/5hcJHtg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3A41618005D for ; Wed, 10 Jul 2024 08:56:32 +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=3.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_PASS, SPF_SOFTFAIL autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from xdebug.org (xdebug.org [82.113.146.227]) (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, 10 Jul 2024 08:56:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1720601704; bh=R6l8svw4jcAgoi+/2oSqNG0wKyFGZKmfaPcGu/ayNm8=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=UeSbpDnEyUY8NW7lIz3GJbMcXdXUp5qASco2HQbdL0180wnKAl4LkdZZef7BpmbvT 6s0Lf5rDS50o7jtIeu+y1Q7K2bIXhL9gnf9fq85yONhV/iyRkf+r24LVFwJj1rED+p u6ktJ5/T2zXw7+/EEuFiZmvf6uUtYf7yf2byB1VyKfzzMIJeIphDXMBXzDhHR+czM3 ehbMJ0/nqVXsxSi2rqkCJ4D+RFRDuNb/RQvdx1uUacprguoYcexo5tmvDDsjC/m3Uh 78rhR3lhTTLtoGf2Q+jISLzS2x+lpk90KL7cu6RJZy1GLPRGOkVPng3hf3lJksCZRL fXNbrcnAtIEXA== Received: from localhost (localhost [IPv6:::1]) by xdebug.org (Postfix) with ESMTPS id 767C410C187; Wed, 10 Jul 2024 09:55:01 +0100 (BST) Date: Wed, 10 Jul 2024 09:55:01 +0100 (BST) To: Saki Takamachi cc: Rob Landers , internals@lists.php.net Subject: Re: [PHP-DEV] [RFC] [Discussion] Add bcdivmod to BCMath In-Reply-To: <3B23E039-D90F-4F84-9ECE-C6A9A3E145AF@sakiot.com> Message-ID: <78a15506-65c5-e29e-86a9-32e921ae9dd5@php.net> References: <668168A7.4040005@adviesenzo.nl> <3B23E039-D90F-4F84-9ECE-C6A9A3E145AF@sakiot.com> Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Content-Type: multipart/mixed; BOUNDARY="8323329-262714967-1720601613=:3691" From: derick@php.net (Derick Rethans) This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-262714967-1720601613=:3691 Content-Type: text/plain; CHARSET=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE On Mon, 1 Jul 2024, Saki Takamachi wrote: > Hi, >=20 > >> Just a suggestion: what about making the returned array an associative > >> array ? Like so: > >> ``` > >> array( > >> 'quotient' =3D> 61, > >> 'remainder' =3D> 1, > >> ); > >> ``` > >> This would remove the need for devs to remember the order of the retur= n > >> values and would make the return value self-documenting. > >=20 > > An associative array would combine the worst of an array (no IDE autoco= mpletion, no strong typing, increased memory usage) with the worst of an ob= ject (no easy way to extract the values into local variables with array des= tructuring). > >=20 > > The example in the RFC doesn't show it, but the following makes the pro= posed API really convenient to use: > >=20 > > $slicesOfPizza =3D new BcMath\Number(8); > > $mouthsToFeed =3D new BcMath\Number(3); > > [$perMouth, $slicesLeft] =3D $slicesOfPizza->divmod($mouthsToFeed); > >=20 > > Note how the order of values matches the words in the method name. Firs= t the result of 'div', then the result of 'mod=E2=80=99. >=20 >=20 > Thanks, I have added this example to the RFC (Please let me know if you h= ave any problems). The example has: =09[$perMouth, $slicesLeft] =3D $slicesOfPizza->divmod($mouthsToFeed); =09=20 =09// $perMouth->value is '2' =09// $slicesLeft->value is '2' Shouldn't that be (without the ->value) ? =09[$perMouth, $slicesLeft] =3D $slicesOfPizza->divmod($mouthsToFeed); =09=20 =09// $perMouth is '2' =09// $slicesLeft is '2' cheers, Derick --8323329-262714967-1720601613=:3691--