On 30 September 2010 15:44, Adam Harvey <[email protected]> wrote:
> Well, while I'm sending e-mails...
>
> 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!
>
> Thanks,
>
> Adam
[5] => strcmp
[6] => strncmp
[7] => strcasecmp
[8] => strncasecmp
[99] => variant_cmp
[403] => strnatcmp
[404] => strnatcasecmp
[1211] => gmp_cmp
vs
[431] => substr_compare
[869] => version_compare
[1302] => collator_compare
[1428] => ldap_compare
var_cmp() looks a LOT like variant_cmp() (Windows only - a function in
the COM/DOTNET extension)
and
variable_compare($a,$b) is actually longer than ($a<$b?-1:(($a>$b)1:0)
But var_cmp() would be my +1
Richard.
--
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php