Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49819 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66348 invoked from network); 30 Sep 2010 15:12:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Sep 2010 15:12:05 -0000 Authentication-Results: pb1.pair.com smtp.mail=rquadling@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rquadling@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.83.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: rquadling@gmail.com X-Host-Fingerprint: 74.125.83.42 mail-gw0-f42.google.com Received: from [74.125.83.42] ([74.125.83.42:54535] helo=mail-gw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3E/B4-43687-5C8A4AC4 for ; Thu, 30 Sep 2010 11:12:05 -0400 Received: by gwj15 with SMTP id 15so411579gwj.29 for ; Thu, 30 Sep 2010 08:12:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:reply-to :in-reply-to:references:from:date:message-id:subject:to:cc :content-type:content-transfer-encoding; bh=LPHkhmAww0sDAXCUvLmCf3DAJpZHfxY2v4Bh6LQarX4=; b=WI9+sAheQ6+W3bJBnZaP758St5grWlxOot03GgOMtN1OS4u2DdUoief4q3IjeiJsrl kvMrhb6lqaLjjuh0awAyoh55mwd6Elw7ELZK20Vw2esbvrUMOCHOvyGS9Sn6QCrKbJ5M N708Uqth8uR/iehDSf92Zb0fPAenmPLq20ZX8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; b=Vu5rK/MyHTOpXUElAqz5J0GI4x5x3mzNn7pmU6xxJwgz674nkJttuxKh6lj1wXCyPN r0FrW3kubcLdL6fGPSmfDpvDWA2umszrc26L62eMMvEjUHJXd+r3tIg7aC07dBMmAj8/ sXv4MbqbonuwcVVqzKEk1GRlUkL9OnX5ol/Lo= Received: by 10.229.186.137 with SMTP id cs9mr2777875qcb.71.1285859522817; Thu, 30 Sep 2010 08:12:02 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.20.1 with HTTP; Thu, 30 Sep 2010 08:11:39 -0700 (PDT) Reply-To: RQuadling@googlemail.com In-Reply-To: References: Date: Thu, 30 Sep 2010 16:11:39 +0100 Message-ID: To: Adam Harvey Cc: PHP internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Expose compare_function() to userspace From: rquadling@gmail.com (Richard Quadling) On 30 September 2010 15:44, Adam Harvey 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) { > =C2=A0return -1; > } > elseif ($a > $b) { > =C2=A0return 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] =3D> strcmp [6] =3D> strncmp [7] =3D> strcasecmp [8] =3D> strncasecmp [99] =3D> variant_cmp [403] =3D> strnatcmp [404] =3D> strnatcasecmp [1211] =3D> gmp_cmp vs [431] =3D> substr_compare [869] =3D> version_compare [1302] =3D> collator_compare [1428] =3D> 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. --=20 Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY