Newsgroups: php.internals
Path: news.php.net
Xref: news.php.net php.internals:122998
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 081E21A009C
	for <internals@lists.php.net>; Sat,  6 Apr 2024 13:43:53 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail;
	t=1712411063; bh=n8orAEzpPt3QOvp/bBj0R6buoLmbjTZmvPNasKPblwk=;
	h=Date:Subject:To:References:From:In-Reply-To:From;
	b=YComTVJKuRGXQYPPffXdK8QnkPDpacH+5mZAXXijlIXQ1g5d2nbHviDcZU1RWlcl4
	 ho7HpM892RxJZ+FDEppOUNx9MC4M0JnZvVOlLN8pG7j+wUal+0IdcmmrqWU3WV6EoP
	 Y+laoihMJScd8pH8BNnlz4Fb9fdixBjySQdhu/6yEvJWmeRpWRQVLdTEifgJU9NSPB
	 DQsV/mwjLUilcUSeFKcibOl+83uJjclVLdfOca+gsrIgfhtLYDafRhW7x+/Bc/Oyut
	 HNxCDKvwbM5b+f/5KbGkvmorQSrX7hi7D1eRvJLAJlLUghynppvcR90PcqccbvWfQT
	 BSeum1nAKAAzQ==
Received: from php-smtp4.php.net (localhost [127.0.0.1])
	by php-smtp4.php.net (Postfix) with ESMTP id 45A6F180A34
	for <internals@lists.php.net>; Sat,  6 Apr 2024 13:44:19 +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.1 required=5.0 tests=BAYES_50,DKIM_SIGNED,
	DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE,
	RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE
	autolearn=no autolearn_force=no version=4.0.0
X-Spam-Virus: No
X-Envelope-From: <imsop.php@rwec.co.uk>
Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24])
	(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 <internals@lists.php.net>; Sat,  6 Apr 2024 13:44:18 +0000 (UTC)
Received: from compute4.internal (compute4.nyi.internal [10.202.2.44])
	by mailout.west.internal (Postfix) with ESMTP id 2083432000D9
	for <internals@lists.php.net>; Sat,  6 Apr 2024 09:43:47 -0400 (EDT)
Received: from mailfrontend2 ([10.202.2.163])
  by compute4.internal (MEProxy); Sat, 06 Apr 2024 09:43:47 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; h=cc
	:content-type:content-type:date:date:from:from:in-reply-to
	:in-reply-to:message-id:mime-version:references:reply-to:subject
	:subject:to:to; s=fm2; t=1712411026; x=1712497426; bh=/LYePwWexM
	0W5xTFhjPs77BC/Nty6ToV+RuOjimrf6A=; b=G8W/pKG8BRfUfHbd8b75qeT3gR
	8pzweJnT6elY8wxw+c4nVnYi8QpCEU3PCcjDBgtLOzrwWXNy0rdarwUgVzCcXW+x
	59chzWNkU6qzvKF6gOhLq7IHbuaclMdewhGmWTEHMCaUT3Bjc2ZSqLO2sOEG7SP5
	YtNxZMhiSlUmBInofUUu3Dl0PCX4lLzzzid5evplFUxWt3K4pb4RPAjC63NoEjNP
	07fZ9CHqNdfQeidr1kpY+UB03/BYB/0yIETOxqgkjhudvD9Tbibf6/kqkj/8HV+z
	fsnxDdF/N/Qbb1qFEi9ELUi70i8cmvsvCq+B+tgqQo+5xnrGSYAgStk4c6Og==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
	messagingengine.com; h=cc:content-type:content-type:date:date
	:feedback-id:feedback-id:from:from:in-reply-to:in-reply-to
	:message-id:mime-version:references:reply-to:subject:subject:to
	:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=
	fm2; t=1712411026; x=1712497426; bh=/LYePwWexM0W5xTFhjPs77BC/Nty
	6ToV+RuOjimrf6A=; b=ruZNe9fvQkqQtkBjO9L+W4n6kxhaVibuLdCzkvSlHKS5
	bWGpUsJXZpNBGE4WCjmUAaNjSueEPnAuwkmxR00M0kofs6W0TWV9NOYlCt8xi0cR
	ZT4f5EdvSp2Oi8FPWT9rBLNdn71EP4BVMmG9IEPinjoHD8s7VsFAnMiy52QYBZHX
	RZcMzQpbzxvODlUEisWu9LFW7CAgfWnBqjGefG5meqXltrJek3BLyipxgl4OQTWx
	z32VtAKYJeX6Di8AcgCPHistQPekfT31XK0nXOllgPmRvpNxaPFJVHxoWHBaelhA
	zH1nQwSFWUUtPXj5a/n5vu0awyhFtpmrWnc5HXaSWQ==
X-ME-Sender: <xms:klERZtMgLh1Pd6MW4OwdOymCAP4Fk2oQftL2AsoB6l4Pn3db7qgPoA>
    <xme:klERZv-nm2K5-6ElKL5xcaoLvTG6Rb6Mu7CRO9R0AJqVOr5o5VD4iSisbq4Epai53
    ugDtLQNKRdokfRb6VI>
X-ME-Received: <xmr:klERZsT5qc1JiW5otnJyP9F_X-UEtf3OWLv0-rIDO8JlzFg0g2at6THLxR1V8yx1BVu0UZgs-7R31ylDQqsG671KGen9c3CTqMnLkLUxoCLqEYgJMteI_k7R>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudegvddgjedtucetufdoteggodetrfdotf
    fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen
    uceurghilhhouhhtmecufedttdenucenucfjughrpegtkfffgggfuffvfhfhjgesrgdtre
    ertddvjeenucfhrhhomhepfdftohifrghnucfvohhmmhhinhhsucglkffoufhorfgnfdcu
    oehimhhsohhprdhphhhpsehrfigvtgdrtghordhukheqnecuggftrfgrthhtvghrnhephe
    etleeiiefgueduieeuieffvdevheduueefkeejuefgffeftdeitdegtedtleetnecuvehl
    uhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepihhmshhophdrph
    hhphesrhifvggtrdgtohdruhhk
X-ME-Proxy: <xmx:klERZpvcWMXiHGuynBIffwEcS9TTBYC_lVE6DX14R2pmSFRPZkWCyQ>
    <xmx:klERZlf0MOIIWLDDf3h7jCY2410nP2ITFsYUCjGkmjFE8iHRVnQF2Q>
    <xmx:klERZl3PeH3I78XzZ7NvLi6dLHhocqYxYZPJNAWQv2zCH4QPmC1h7g>
    <xmx:klERZh9qFznyV366QISU3b974D0W73OJF6_6rasTa7oT_28AbUOgjA>
    <xmx:klERZmqVb6bq1bFcFphlENYPE-skd1l8hXjAsWZ8F6Vp0a9GDYpgtBJrMdxM>
Feedback-ID: id5114917:Fastmail
Received: by mail.messagingengine.com (Postfix) with ESMTPA for
 <internals@lists.php.net>; Sat, 6 Apr 2024 09:43:45 -0400 (EDT)
Content-Type: multipart/alternative;
 boundary="------------VcJX031u40gGhR0xverXtevV"
Message-ID: <b232c9f1-aad9-4ef3-8f23-d0cb2deb0baf@rwec.co.uk>
Date: Sat, 6 Apr 2024 14:43:43 +0100
Precedence: bulk
list-help: <mailto:internals+help@lists.php.net
list-unsubscribe: <mailto:internals+unsubscribe@lists.php.net>
list-post: <mailto:internals@lists.php.net>
List-Id: internals.lists.php.net
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: [PHP-DEV] [RFC] [Discussion] Support object type in BCMath
To: internals@lists.php.net
References: <D1E3EBAD-A991-4591-B7DE-CF414593E64B@sakiot.com>
 <FB449C0E-1D83-476F-889D-19A6ABDBD38E@sakiot.com>
 <FF0FFBCE-7F03-44A2-B7AE-D3F958135ACB@sakiot.com>
Content-Language: en-GB
In-Reply-To: <FF0FFBCE-7F03-44A2-B7AE-D3F958135ACB@sakiot.com>
From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]")

This is a multi-part message in MIME format.
--------------VcJX031u40gGhR0xverXtevV
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

On 06/04/2024 07:24, Saki Takamachi wrote:
> 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.


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.

Regards,

-- 
Rowan Tommins
[IMSoP]

--------------VcJX031u40gGhR0xverXtevV
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <div class="moz-cite-prefix">On 06/04/2024 07:24, Saki Takamachi
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:FF0FFBCE-7F03-44A2-B7AE-D3F958135ACB@sakiot.com">
      <pre>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.</pre>
    </blockquote>
    <p><br>
    </p>
    <p>While this is an intriguing idea, it only solves a narrow set of
      use cases. For instance:<br>
    </p>
    <p>- 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.</p>
    <p>- 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.</p>
    <p>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.<br>
    </p>
    <p>Regards,<br>
    </p>
    <pre class="moz-signature" cols="72">-- 
Rowan Tommins
[IMSoP]</pre>
  </body>
</html>

--------------VcJX031u40gGhR0xverXtevV--