Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123006 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 642E31A009C for ; Sun, 7 Apr 2024 00:25:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1712449534; bh=jOaGZz8+oEHnjryZBujGxdebKQ6KU6zGrsQl+8j8+60=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=lyLLRoGmSDPk90JQpJjRZnnXl+hFDTkEtEv2T11n0hFuFu5IiCvIPnOSiw2naxUuF dQ3zndFuR9SY8XW7pFoF0d4xycyUVwZCXuK6CZV478FxLzRUYFBOZg66yLQ2ze248q MY8mlNyRx9JHBuF6wNSmVCBfdt74RBKwdvVtBOYcsME+Cic6NuYzJvOhRXsRhjbxra ncNzRXtsxSE9MXmgcP09inBma5ImcT0PilF2WIYuPzWIFhFU27cubwDUvbltlcB43V EoyEjq/PY+1XajGnyGIPxl3ebrH1aM+9PuPthZ0S6/w6/Dx8IKbdEnQX8hRmO9QdjU MPExi32V0Bmlg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E032A18006D for ; Sun, 7 Apr 2024 00:25: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=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, 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-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (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 ; Sun, 7 Apr 2024 00:25:32 +0000 (UTC) Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-6eced6fd98aso2886312b3a.0 for ; Sat, 06 Apr 2024 17:25:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712449500; x=1713054300; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=agtqOjhCEGLvvE/IFjqjy+IShDYBD1NGr7NNcQ5wSkQ=; b=G3414nGaAPZVv0VbI8YMRBxvxn4mLHa9dgToslIpY1WmC/VAQ5uMJK70dXub3Uo1k6 +m+jxLxK8hEEyFF8Fmwpnu2Zcp/W6P6sUZpKV5+jXdVEuSHEgBalT/tj0DwXfDDrqL+C KVC4GbhSJcmuFcV+zyJyd8rfoQGIXarOo2M8I3SHbHhdTt/ag427WirgqAvQpziF53st I82ZmwfPWBZ/WBX19SHjgwPfbnZF6UxPise6ZvGF9tOHxe3Mu4dRv8mHQ+PHs7j0Eq0T XeE4rLidlbYlpTTre9AkZOFdOtJjGNISlBYVluqlQlT6gYg9yIa70NnkVf/K+AKtyUdN dSKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712449500; x=1713054300; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=agtqOjhCEGLvvE/IFjqjy+IShDYBD1NGr7NNcQ5wSkQ=; b=QyB4dEOrRfcbmubcE234RSNEAu4cukwHEckxW92pqwpPUWDcQpFZDowR2+rg3bKqxG gbu7haR3DMGojCi858srflje7eylHb0tqKVMLncma1WlbQUTGPKn4N++kGrXsUP+Icqm V1tce8PY3wwDgo4ONxyTK4T3jLA2UaNa8PVJb3ZBrnK1Ot9gkVqBSA48HRfVRJeGMa66 vHmgfzy/CJld4PPSAz615jrC2RfbXr9rlhFSEJiBAEH2n7JQLOTHb7WrD76pomXMZcRq oga7pbTzd6xWfYYNbuxwBcXAS9qgQDK/teeEaaLhGr99r27gl+0RNwX2xlgujo/rAfpM tBIA== X-Gm-Message-State: AOJu0YzmBiJprCujAf4+GhCJ4h7uxGjfqnhez8sypcWwAcVxEE56b0mV E6C6smmKBcB8Fvi/XEZKaKwr5SdG7so/Jfc1q1G9jw7zUac7Z1TaLB5rKLPTf91umjVTc9QH3Eh gWxjBENUh6zberwD/ZRVpLj8vH2toKnmrqWA= X-Google-Smtp-Source: AGHT+IHNEXtNxf9ohdjXd9fbi3+UNnnqVErYJQCdyFCj0l99xy5UK3+0FUAKO3lxTGHOcSCgMdwNGkBZO1BlHJJpUEo= X-Received: by 2002:a05:6a20:9193:b0:1a7:4ac4:c650 with SMTP id v19-20020a056a20919300b001a74ac4c650mr4007025pzd.28.1712449500381; Sat, 06 Apr 2024 17:25:00 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: In-Reply-To: Date: Sat, 6 Apr 2024 17:24:48 -0700 Message-ID: Subject: Re: [PHP-DEV] [RFC] [Discussion] Support object type in BCMath To: "Rowan Tommins [IMSoP]" Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="0000000000002ac9bd061576b8a7" From: jordan.ledoux@gmail.com (Jordan LeDoux) --0000000000002ac9bd061576b8a7 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, Apr 6, 2024 at 6:45=E2=80=AFAM Rowan Tommins [IMSoP] wrote: > 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. > > If only there had been a feature that carefully considered how all those things would interact. Oh well. Okay, then please tell me in which use cases inheritance rather than > composition is the right choice? For the "Money" example, I've already > showcased how it would be broken and I can't think of any example where > inheritance would be superior to composition. > > Yes, my example is dumb, but nevertheless it showcased that the native > and unchangeable operations would be unsound for child classes with > custom properties, because the operations would not be able to correctly > fill in the custom properties. > No, like I said, I disagree, but I don't get a vote AND it's not something I would actually vote no over if I could, so it's not something I'm willing to put the effort into in that way. I was voicing my disagreement to make sure it was part of the discussion but I wasn't trying to put the effort into actually changing the design of the RFC, which I understand is a little unsatisfactory to some. As it is, this RFC will be useful to some for sure, but my library will ignore it. Jordan --0000000000002ac9bd061576b8a7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Sat, Apr 6, 2024 at 6:45=E2=80=AFA= M Rowan Tommins [IMSoP] <imsop.p= hp@rwec.co.uk> wrote:
=20 =20 =20
On 06/04/2024 07:24, Saki Takamachi wrote:
Take a look at the methods shown below:
```
protected static function resultPropertyRules(string $propertyName,=20
mixed $value1, mixed $value2): mixed {}
```

This method determines which operand value to use in the result after=20
calculation for a property that the user has defined by extending the=20
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, &#= 39;USD') should be an error.

- Properties might need to interact with each other; e.g. Distance(2, 'metres') + Distance(2, 'feet') could res= ult 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.



If only there had been a= feature that carefully considered how all those things would interact. Oh = well.

Okay, then please tell me in which use cases inheritance rather than
composition is the right choice? For the "Money" example, I'v= e already
showcased how it would be broken and I can't think of any example where=
inheritance would be superior to composition.

Yes, my example is dumb, but nevertheless it showcased that the native
and unchangeable operations would be unsound for child classes with
custom properties, because the operations would not be able to correctly fill in the custom properties.=C2=A0

N= o, like I said, I disagree, but I don't get a vote AND it's not som= ething I would actually vote no over if I could, so it's not something = I'm willing to put the effort into in that way. I was voicing my disagr= eement to make sure it was part of the discussion but I wasn't trying t= o put the effort into actually changing the design of the RFC, which I unde= rstand is a little unsatisfactory to some.

As it i= s, this RFC will be useful to some for sure, but my library will ignore it.=

Jordan
--0000000000002ac9bd061576b8a7--