-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Implement cmp() function #1006
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
Implement cmp() function #1006
Conversation
why?
you can't change all user used codes into extension function.. |
See my last three emails to internals (replying to Rasmus). Essentially:
|
Why not <=> then? Also, I'm a bit afraid taking "cmp" may be a BC problem. But maybe I'm too paranoid. I like the idea though. |
@smalyshev Yeah, we could just add the operator Perl has, actually. It reads pretty well. I'm sure some would object to the syntax, though, but
Maybe this'll end up just like the |
I suppose an advantage of |
|
Here's an argument against |
@TazeTSchnitzel I've got a idea to fix that issue... running test, thanks |
@laruence Good, but it doesn't really remove the need for this. |
@TazeTSchnitzel actually, I like @smalyshev 's <=> idea |
@laruence I do too, I'm also making a patch for that |
@TazeTSchnitzel as I said, we are not baby-sitter, you can not change any user common used PHP codes into PHP internal function... |
This isn't baby-sitting, it's a basic language feature... Ruby, Perl, Groovy, Python 2 (but not 3?!), Haskell, OCaml, all of these have this. |
@TazeTSchnitzel I was talking about cmp, not <=> :) |
@laruence They're exactly the same, though. If there's a case for an operator, I don't see why there isn't a case for a function. |
Ruby, Perl, Groovy have |
I feel it is overhead, how different between function ($a, $b) { return $a <=> $b; } and a builtin cmp? |
Nothing, but that's assuming we have |
Made a |
Wow unit tests hate |
Also see Implement <=> (spaceship/comparison) operator