On Thu, Sep 30, 2010 at 16:44, Adam Harvey <ahar...@php.net> 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;

I'm a bit confused...

Are you proposing a new PHP function to check if 2 integers are equal?
The usecase being a callback function for u*sort()?

What happens when it gets passed an string? or an object with a
__toString() ? the string "100$ USD"?

I am a bit skeptical here..
Sure, I have written that code snippet millions of times, but I have
also written that between() snippet million times..
Don't think it deserves to become a PHP core function though.
When I write the function I can atleast control what happens with
non-ints.. like if ($a instanceof ValueObject) { $a->getNumeric() ..

Can't see the point of adding the trillionth "helper" function into PHP.

-Hannes

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

Reply via email to