Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49815 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 59638 invoked from network); 30 Sep 2010 14:44:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Sep 2010 14:44:34 -0000 Authentication-Results: pb1.pair.com smtp.mail=adam@adamharvey.name; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=adam@adamharvey.name; sender-id=pass Received-SPF: pass (pb1.pair.com: domain adamharvey.name designates 209.85.214.170 as permitted sender) X-PHP-List-Original-Sender: adam@adamharvey.name X-Host-Fingerprint: 209.85.214.170 mail-iw0-f170.google.com Received: from [209.85.214.170] ([209.85.214.170:41509] helo=mail-iw0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 74/53-43687-152A4AC4 for ; Thu, 30 Sep 2010 10:44:33 -0400 Received: by iwn37 with SMTP id 37so2950647iwn.29 for ; Thu, 30 Sep 2010 07:44:31 -0700 (PDT) Received: by 10.231.155.7 with SMTP id q7mr3855320ibw.105.1285857870500; Thu, 30 Sep 2010 07:44:30 -0700 (PDT) MIME-Version: 1.0 Sender: adam@adamharvey.name Received: by 10.231.79.3 with HTTP; Thu, 30 Sep 2010 07:44:01 -0700 (PDT) Date: Thu, 30 Sep 2010 22:44:01 +0800 X-Google-Sender-Auth: HqZoUH1kT5iAi0Gnk_NO0VdlvrQ Message-ID: To: PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Expose compare_function() to userspace From: aharvey@php.net (Adam Harvey) 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