Expose compare_function() to userspace

From: Date: Thu, 30 Sep 2010 14:44:01 +0000
Subject: Expose compare_function() to userspace
Groups: php.internals 
Request: Send a blank email to internals+get-49815@lists.php.net to get a copy of this message
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

« previous php.internals (#49815) next »