Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122984 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 723221A009C for ; Fri, 5 Apr 2024 20:00:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1712347265; bh=hoBjNJ2E/A3qzV8i3U0yFOm62lNlhqQIdJhY3xWxxQQ=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=TastBait1AwoijnizeUXgFgGoEtnc18HzkeHVsjDKamQ2SLsqf6wq5aqVx70tubkG LEo7DoOtlqxQKS8r3gErAUW45kDpSP+b+0ng+Mb0GEMbyhFJ2UxAui1co0tsSm6pgz nSM1/XS1FQ4l/rDzY9HQgbWqb8GExSG8maHrjZ2J2wA3YKgTG43w5D55brkPUiOV+L bVxdwlOPaBsJVFd1qQ2TcXfEbzmGQOhkpEK6PzkzKxZbz02oM/qzGMIWv0C64KGA6X fb0bByt/vDciPb3Z6zoLUUZIvWi49af4RnZkw5UX0dQdnDoc9AIxzeRiETaNbwwaIr OI3xadOErdd8A== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 90B48180C1A for ; Fri, 5 Apr 2024 20:01:04 +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 chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 5 Apr 2024 20:01:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1712347233; bh=1znV5qjWDW9LRHw1udBdrFNlZBYq6tJkTC/E6HGRQdU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type:from:to:cc:subject:message-id; b=Pivz5R+zm58TiDdoz/WkvrHZ22WOf5lKXWNxs2SvNL4dgV43btBDwKPcooYYUbNc6 hPGuwqD0JFZJXOpCSGp/qiauoN2W9XAOmo4VhBoyySO+j6KQsZd7VALI4chbyYEnEV slm47589H83oAaFgwpWy1ALYWrd2pN6ThHdUd+qth6gQ1vtQUFyvqKMJ+4nRh9U6n6 lmIN+CN6ULsobzSMA/w/fOW0PbQGRQ0aAGMpSHSTvR9jS1SXMgPL/FQ7ohWGT5uk8i 7VbsphaS8HGdAXHgjX1JvSHjQBwzzA1icEkIikUGmHqoNymiW2M6vvabq9wOEzQHGD K/VpJ8xNg8sRw== Message-ID: Date: Fri, 5 Apr 2024 22:00:32 +0200 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Subject: Re: [PHP-DEV] [RFC] [Discussion] Support object type in BCMath To: Saki Takamachi , Jordan LeDoux Cc: Lynn , Aleksander Machniak , php internals References: <46B14427-44B2-4665-BC14-6018AC34B0CF@sakiot.com> Content-Language: en-US In-Reply-To: <46B14427-44B2-4665-BC14-6018AC34B0CF@sakiot.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi On 4/5/24 21:42, Saki Takamachi wrote: > The only solution I can think of at the moment is to impose the constraint that > when computing operator overloading, if the operands are both objects, they must > be of the exact same class. Even that would allow for confusing behavior: class MyNumber extends Number { private $importantMetadata; public function doSomething() { $this->importantMetadata = random_int(1, 100); } } $a = new MyNumber(5); $a->doSomething(); $b = new MyNumber(10); $b->doSomething(); $what = $a + $b; What should be the value of $what->importantMetadata be? The property is private, so as a user adding two of MyNumber would not even be able to manually fix it up with the correct value, thus requiring the addition of a "fixup" method that fixes the internal state of the object, possibly even lacking the necessary information to properly fix up the state, because it does not know which operations lead to the state. Best regards Tim Düsterhus