-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[RFC] User-defined object comparison #3339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I was playing with this recently (based on Java): https://gist.github.com/Majkl578/e71828d2a146a5cad34ccb893171f6ab |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great RFC :)
Nit: some tests don't need EXPECTF
, we can use EXPECT
4cdb098
to
5da5218
Compare
@carusogabriel Thanks for the suggestion! Fixed them all in 7f40bf2. |
Can someone help me debug what's happening with inheritance here? When
There are multiple failures all over the place but this is a good one to inspect. That test file is here, and the included file is here. it's worth noting that taking out that include and embedded the contents in that .phpt file has no effect on the output. |
@rtheunissen The debug=0 build is with opcache. You're missing an update to https://github.com/php/php-src/blob/master/ext/opcache/zend_accelerator_util_funcs.c#L425 -- pointers to methods need to be rewired to point into the CG arena. |
I'm slightly worried about the behavior of weak comparison after this change. Given the discussion in #3297 (comment), this may make things more confusing. I'm afraid that if this RFC was implemented sooner, it would make things more confusing. |
|
95519dc
to
20a1efc
Compare
This reverts commit bc3eda5.
e490eba
to
7bbae20
Compare
Closing due to declined RFC. |
@rtheunissen Is it possible to find any information about why it was declined? I need object equality quite often in tests so I'm curious what led to declining this. I've searched mailing lists but without any success, maybe because I can't work with them, I don't know.. |
I was just doing the same, haven't found it yet either. Seems like the vote went through without any discussion. Now I often write my own compare function in a class (typescript)
|
I think maybe I just didn't build enough consensus before the vote happened. The most common objection I heard was that a comparator should always be external, provided, never implicit. I don't agree with that.. if you want to override implicit behavior or compare in a non-standard way you can provide a comparator, but the object itself should know how it compares to others in a standard way. Other languages support this.. Python, C++, etc. I still think this is a good idea. |
Is there anyway to re do this voting/rfc? PHP kinda feels unnecessarily rigid because of this |
I'm coming back to some extension work and I am once again wishing this was approved. I remember being rushed into a vote because the next version of PHP at the time was coming up quickly and I didn't want to wait for the next version. I still believe that this is a good strategy for PHP. What is the process of potentially re-opening the discussion? |
RFC: https://wiki.php.net/rfc/object-comparison