Re: [PHP-DEV] Custom object equality

2023-10-25 Thread G. P. B.
I am just going to put this out there, but I will vote against any RFC which provides access to userland to overload == and <=> until the base semantics of PHP comparisons are fixed and the necessary engine prerequisite work is done. I am working on such an RFC, as I frankly do not trust people to

Re: [PHP-DEV] Custom object equality

2023-10-24 Thread Dik Takken
On 23-10-2023 22:07, Jordan LeDoux wrote: I don't quite follow. The interface would cause the engine to use the result of an `equals()` function on the object if it implements an interface as part of `zend_compare`? Internally there is no `==` function, there is only the equivalent of `<=>`. To i

Re: [PHP-DEV] Custom object equality

2023-10-24 Thread Marc Bennewitz
Hi Jordan, On 23.10.23 22:07, Jordan LeDoux wrote: Implementing the compare handler for an overload requires adding two new entries to ZEND_AST_BINARY_OP because the `>` and `<` comparisons have to be preserved in the AST in order to call the correct object handler. THAT requires updating OpCach

Re: [PHP-DEV] Custom object equality

2023-10-23 Thread Jordan LeDoux
On Mon, Oct 23, 2023 at 10:20 AM Dik Takken wrote: > On 23-10-2023 18:34, Larry Garfield wrote: > > > > Jordan's RFC explained in detail why interfaces are not viable, which is > why we have to use magic methods (with or without a special keyword) > instead: > > > > > https://wiki.php.net/rfc/use

Re: [PHP-DEV] Custom object equality

2023-10-23 Thread Dik Takken
On 23-10-2023 18:34, Larry Garfield wrote: Jordan's RFC explained in detail why interfaces are not viable, which is why we have to use magic methods (with or without a special keyword) instead: https://wiki.php.net/rfc/user_defined_operator_overloads#why_not_interfaces (Seriously, it has an e

Re: [PHP-DEV] Custom object equality

2023-10-23 Thread Larry Garfield
On Mon, Oct 23, 2023, at 3:14 PM, Dik Takken wrote: > On 18-10-2023 14:50, someniatko wrote: >> This approach allows combining >> - no BC break - `~=` is a new syntax which is unavailable in older PHP >> versions >> - explicitly showing an intent that objects are compared using a custom >> comparis

Re: [PHP-DEV] Custom object equality

2023-10-23 Thread Dik Takken
On 18-10-2023 14:50, someniatko wrote: This approach allows combining - no BC break - `~=` is a new syntax which is unavailable in older PHP versions - explicitly showing an intent that objects are compared using a custom comparison, rather than standard PHP one - allow to skip writing boilerplat

Re: [PHP-DEV] Custom object equality

2023-10-19 Thread Jordan LeDoux
On Thu, Oct 19, 2023 at 12:14 AM Pierre wrote: > > Maybe I don't master english enough and I can speak to strictly > sometime. If an operator overload RFC that doesn't have any blind spot > or weird edge case happens, I'd be happy to see it pass, at least it > would close bike shedding around thi

Re: [PHP-DEV] Custom object equality

2023-10-19 Thread Craig Francis
On 18 Oct 2023, at 13:50, someniatko wrote: > There were already suggestions on the mailing list to allow "overloading" > existing `==` operator, and some suggestions went even as far as overloading > `<`, `>=` etc operators. Slightly off-topic, but concatenation? Just as a possible feature..

Re: [PHP-DEV] Custom object equality

2023-10-19 Thread Sven Michael Klose
On 10/18/23 20:20, Lanre Waju wrote: I believe it's time to shift our focus away from backward compatibility (BC) concerns in major versions. In my opinion, genuine operator overloading is incomparable to the pseudo operator. I genuinely see the operator overloads as an invaluable addition to P

Re: [PHP-DEV] Custom object equality

2023-10-19 Thread Pierre
Le 18/10/2023 à 22:22, Jordan LeDoux a écrit : While I (obviously) appreciate the goal of the proposal here since I wrote the gigantic operator overload RFC the last time it was proposed, I do not support this idea here for one very simple reason: it is a clunky, work-around implementation to

Re: [PHP-DEV] Custom object equality

2023-10-18 Thread Robert Landers
On Wed, Oct 18, 2023 at 10:22 PM Jordan LeDoux wrote: > > On Wed, Oct 18, 2023 at 6:03 AM Pierre wrote: > > > Le 18/10/2023 à 14:50, someniatko a écrit : > > > Hi internals, > > > > > > This approach allows combining > > > - no BC break - `~=` is a new syntax which is unavailable in older PHP > >

Re: [PHP-DEV] Custom object equality

2023-10-18 Thread Jordan LeDoux
On Wed, Oct 18, 2023 at 6:03 AM Pierre wrote: > Le 18/10/2023 à 14:50, someniatko a écrit : > > Hi internals, > > > > This approach allows combining > > - no BC break - `~=` is a new syntax which is unavailable in older PHP > > versions > > - explicitly showing an intent that objects are compared

Re: [PHP-DEV] Custom object equality

2023-10-18 Thread Tim Düsterhus
Hi On 10/18/23 18:42, Larry Garfield wrote: Honestly I'm still on team operator-override. *Most* major languages have operator overloading, and it doesn't seem to cause a problem. (According to my research, C++, Kotlin, Swift, Rust, C#, Haskell, Python, and Ruby all have operator overloading

Re: [PHP-DEV] Custom object equality

2023-10-18 Thread Lanre Waju
I believe it's time to shift our focus away from backward compatibility (BC) concerns in major versions. In my opinion, genuine operator overloading is incomparable to the pseudo operator. I genuinely see the operator overloads as an invaluable addition to PHP 9 Lanre On 2023-10-18 6:50 a.m.,

Re: [PHP-DEV] Custom object equality

2023-10-18 Thread Deleu
On Wed, Oct 18, 2023 at 2:05 PM Christian Schneider wrote: > Am 18.10.2023 um 18:42 schrieb Larry Garfield : > > So the real question is: Would anyone who voted No on operator > overloading before vote Yes on it if it used ~=, ~>, ~+, etc. instead? > > I confess that I'm not a fan of operator ov

Re: [PHP-DEV] Custom object equality

2023-10-18 Thread Lynn
On Wed, Oct 18, 2023 at 2:51 PM someniatko wrote: > Hi internals, > > There is often a need to compare whether two objects are equal. For > example, a popular [brick/money]( > https://packagist.org/packages/brick/money) > library has a `Money` class, which has an `equals()` method. However, this

Re: [PHP-DEV] Custom object equality

2023-10-18 Thread Robert Landers
On Wed, Oct 18, 2023 at 7:05 PM Christian Schneider wrote: > > Am 18.10.2023 um 18:42 schrieb Larry Garfield : > > So the real question is: Would anyone who voted No on operator overloading > > before vote Yes on it if it used ~=, ~>, ~+, etc. instead? > > I confess that I'm not a fan of operato

Re: [PHP-DEV] Custom object equality

2023-10-18 Thread Christian Schneider
Am 18.10.2023 um 18:42 schrieb Larry Garfield : > So the real question is: Would anyone who voted No on operator overloading > before vote Yes on it if it used ~=, ~>, ~+, etc. instead? I confess that I'm not a fan of operator overloading for a language like PHP but introducing new operators on

Re: [PHP-DEV] Custom object equality

2023-10-18 Thread Larry Garfield
On Wed, Oct 18, 2023, at 1:12 PM, Robert Landers wrote: > On Wed, Oct 18, 2023 at 2:51 PM someniatko wrote: >> >> Hi internals, >> >> There is often a need to compare whether two objects are equal. For >> example, a popular [brick/money](https://packagist.org/packages/brick/money) >> library has a

Re: [PHP-DEV] Custom object equality

2023-10-18 Thread Robert Landers
On Wed, Oct 18, 2023 at 2:51 PM someniatko wrote: > > Hi internals, > > There is often a need to compare whether two objects are equal. For > example, a popular [brick/money](https://packagist.org/packages/brick/money) > library has a `Money` class, which has an `equals()` method. However, this >

Re: [PHP-DEV] Custom object equality

2023-10-18 Thread Pierre
Le 18/10/2023 à 14:50, someniatko a écrit : Hi internals, This approach allows combining - no BC break - `~=` is a new syntax which is unavailable in older PHP versions - explicitly showing an intent that objects are compared using a custom comparison, rather than standard PHP one - allow to ski