Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122999 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 223561A009C for ; Sat, 6 Apr 2024 15:07:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1712416079; bh=nVaNraaB8TolMoir3e6n8UxNCUG9ielgCIR3Rtv/poE=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=e/kfY3fdape6hV4ex7vaj9tbpuJYUXm3JfyR7SwvDCI9WCmKGZclav0P5cBd182Py 65VUziVCK0vApvKVlBPtdWlr0lbA93JNLKpih1ha180eUtZsYuqH83p0FNOJFxbJ0b 0PGj9lGYyJg0Nk9g9HzK/Nz+elUpVeT3sealX76GnCNy8JYm0M5j0v5RB/CW/mNDr8 d9/oFag2iANcY1XdNpH809MeqaG6hNN28h169BLxAwWC2qsLspR4UMymipy0jUIj4l urn37+Y1BQ1eSzl+Z3d7dydVxnNPF7hqXDlhKt0g9Q83r/z7QpRr5xpBUtA7NJXPCt Yi6KcvrJk5MaQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id CE00618005D for ; Sat, 6 Apr 2024 15:07:55 +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 15:07:54 +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 E38F8401CC; Sun, 7 Apr 2024 00:07:20 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=sakiot.com; s=default; t=1712416040; bh=nVaNraaB8TolMoir3e6n8UxNCUG9ielgCIR3Rtv/poE=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=qf6Q9O2GpFjm4p0Jz7FNFY+fieuvOiifXg4pzos10T2ZEWC4S/zplH8NjH7D3aZT8 c7ZICNfIjZAbJyhaknBCV+JSRTSaiVW/5DWBnK65d9fUHZJWF84MB5W2vPvZg5hdLT 7d0XSZuqSpiKdqpazA4BcrFsWerYZJikh6PvDspw= Content-Type: text/plain; charset=us-ascii 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: Sun, 7 Apr 2024 00:07:08 +0900 Cc: internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: References: To: "Rowan Tommins [IMSoP]" X-Mailer: Apple Mail (2.3731.700.6.1.1) From: saki@sakiot.com (Saki Takamachi) Hi Rowan and folks, > While this is an intriguing idea, it only solves a narrow set of use = cases. For instance: > - The class might want different behaviour for different operations; = e.g. Money(42, 'USD') + Money(42, 'USD') should give Money(84, 'USD'); = but Money(42, 'USD') * Money(42, 'USD') should be an error. > - Properties might need to interact with each other; e.g. Distance(2, = 'metres') + Distance(2, 'feet') could result in Distance(2.6096, = 'metres'); but if you calculate one property at a time, you'll end up = with Distance(4, 'metres'), which is clearly wrong. > The fundamental problem is that it ignores the OOP concept of = encapsulation: how an object stores its internal state should not define = its behaviour. Instead, the object should be able to directly define = behaviour for the operations it supports. Thank you for pointing it out. Given what Tim and you mentioned, trying = to make BCMath\Number have more than just "a value" is probably the = wrong approach. (Except for some properties for rationality of = calculation) Inheritable classes are attractive, but there are too many problems to = solve to make them a reality, some of which are probably impossible to = solve. I explored various possibilities, but in the end, I think making = it a final readonly class is the healthiest option. To you all: The discussions thus far have been reflected in the RFC. I would be very = happy if you could check it out. (Thanks Tim, the tag is very easy = to read.) https://wiki.php.net/rfc/support_object_type_in_bcmath Regards. Saki=