Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122992 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 A7F511A009C for ; Sat, 6 Apr 2024 06:24:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1712384717; bh=IVbClgIlrCE7zup61FAOCLdhztOKZfUDPgf3jxYv33Y=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=fPfjgVqo7ljvjZi1tDSWlN4e01tLDa7MNs2m7il2CGTT2Ign7vAGz6kTUQTCcYGlg GxBDbxldBI0LRksi9dGltV7OTLZI+CHi5HBb/KmZFgnxcryHviGZFOKVKDmkfAr7NY VKRG3NPM7m3zEd/mJgWBQXE0CBKAWb9KqtjvORZ6k0r0VvgHnr1pc5iF3DsUEBBt2i toeZVxhKVKiT7ajv4azMUuJ73V5LOkm/csn6CeRmgIAGi95dQ0oGY60OAlIfyYaG6N 10wdcWc/3fLgweBQr9wYpo3CddGjCVjic/86B3rK+caEBleUSmd1DvR5cgjeRE7wn/ 696GHim3tod5w== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BFBEE180047 for ; Sat, 6 Apr 2024 06:25:13 +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,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.sakiot.com (mail.sakiot.com [160.16.227.216]) (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 ; Sat, 6 Apr 2024 06:25:12 +0000 (UTC) Received: from smtpclient.apple (unknown [117.55.37.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.sakiot.com (Postfix) with ESMTPSA id E37D4401D9; Sat, 6 Apr 2024 15:24:38 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=sakiot.com; s=default; t=1712384678; bh=IVbClgIlrCE7zup61FAOCLdhztOKZfUDPgf3jxYv33Y=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=LyS8iz/DAVs99nZF2Zco3WmPC9wc5ZW1C9xfzrO3dtKkpsIygBHaqVaJOc4kl9XQo P8LH+YYqhZQSw+c1kIZmBGJdL2LVQ7N0MkEQTWkCp+BpgPSyx8f0x1T+1nlpQVGHr+ 0BwqULXjVHO2sErBCYpSJVsLj3sJkJSIhU0lMgMU= Content-Type: text/plain; charset=utf-8 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6.1.1\)) Subject: Re: [PHP-DEV] [RFC] [Discussion] Support object type in BCMath In-Reply-To: Date: Sat, 6 Apr 2024 15:24:26 +0900 Cc: =?utf-8?Q?Tim_D=C3=BCsterhus?= , Lynn , Aleksander Machniak , php internals Content-Transfer-Encoding: quoted-printable Message-ID: References: To: Jordan LeDoux X-Mailer: Apple Mail (2.3731.700.6.1.1) From: saki@sakiot.com (Saki Takamachi) > I'll try to think of some more good ideas, but if you have any = suggestions, please let me know. Regarding `$roundMode`, a possible approach is to clarify the priority = of the current eight values, and if they are different, apply the one = with the higher priority. With that in mind, the question that remains is which of the following = three elements should I give up on? 1. User freedom (inheritability) 2. Commutativity of computation 3. Simplicity Giving up on 1 means adopting a final class. Giving up 2 means always = prefering the left operand to determine the properties of the result. = (However, I don't really like giving up 2) In this email, I will explain the approach if you give up on 3. This is = an approach I just came up with earlier. Take a look at the methods shown below: ``` protected static function resultPropertyRules(string $propertyName, = mixed $value1, mixed $value2): mixed {} ``` This method determines which operand value to use in the result after = calculation for a property that the user has defined by extending the = class. Calling this in the Number class is pointless and will throw an = exception. Child classes may not necessarily need to override this. Here are the details. These examples assume that all calculations are = performed between objects of classes that inherit from Number. = Additionally, "properties" in the description refer to properties = defined by the user. - Objects to be calculated must be a parent-child relationship or be of = the same class. - If they are different objects (parent-child relationship), the = calculation result will always be the class of the child. - `resultPropertyRules()` is not called if it is possible to implicitly = determine which properties the result should have. - If cannot determine the value of a property that the result should = have, call `resultPropertyRules()` for that property. In other words, = `resultPropertyRules()` is called as many times as there are properties = that need to be evaluated. - If `resultPropertyRules()` needs to be called and = `resultPropertyRules()` is not overridden, an exception will be thrown. - Similarly, if use `resultPropertyRules()` and the value cannot be = determined properly (for example, if it returns a value of a different = type), it will also throw an exception. Supplement: Example when it is possible to determine the value to be = used implicitly - If the user has not defined the property - If all property values =E2=80=8B=E2=80=8Bare exactly the same - For objects in a parent-child relationship, if a certain property = exists only on the child side Points that need discussion - Suppose that in an object with a parent-child relationship, a certain = property is defined on the parent side. In that case, which definition = should be used for `resultPropertyRules()`, parent or child? - A more specific case of the above question: What if the visibility of = the property defined in the parent is private? Regards. Saki=