On Thu, September 30, 2010 9:44 am, Adam Harvey wrote:
> Unrelated to the Comparable RFC, are there any objections to adding a
> function that simply wraps compare_function()? It's depressingly
> common to end up writing a construct like the following in comparison
> callbacks, so I think we might as well encapsulate the pattern in an
> actual function:
>
> if ($a < $b) {
>   return -1;
> }
> elseif ($a > $b) {
>   return 1;
> }
> return 0;
>
> If I don't hear kicking and screaming in the next few days, I'll slip
> this into trunk. I can provide a patch/RFC in advance if there's
> demand, but it'll be about as simple as you imagine. :)
>
> The one thing that I would like bikeshedding^Wfeedback on is the name:
> cmp() makes the most sense to me, since it lines up well with Python
> and (to a lesser extent) Perl, but if there are concerns about
> potential name clashes with existing code, may I suggest
> var_compare(). Get your votes and/or suggestions in!

I don't really think we need this in core.

I mean, yeah, I may have written the same function a few times, but
it's not exactly brain surgery. (which I've been through so I know :-)

Except for handling non-int input, which you probably won't do in the
core function anyway...

Seems kind of a pointless bloat to this developer.

-1

PS
It should be INT_cmp if it takes INT.  Or num_cmp or number_cmp

var_cmp et al would imply any sort of var...

Though I guess using < and > means it would do whatever those
operators do for Objects, strings, or resources...  Which I wouldn't
even want to try to predict and rely on anyway.

-- 
brain cancer update:
http://richardlynch.blogspot.com/search/label/brain%20tumor
Donate:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FS9NLTNEEKWBE



-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to