Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49839 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 70887 invoked from network); 1 Oct 2010 16:45:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Oct 2010 16:45:48 -0000 Authentication-Results: pb1.pair.com header.from=hannes.magnusson@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=hannes.magnusson@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.170 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: hannes.magnusson@gmail.com X-Host-Fingerprint: 209.85.216.170 mail-qy0-f170.google.com Received: from [209.85.216.170] ([209.85.216.170:40266] helo=mail-qy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3C/E8-20252-B3016AC4 for ; Fri, 01 Oct 2010 12:45:48 -0400 Received: by qyk35 with SMTP id 35so3647125qyk.8 for ; Fri, 01 Oct 2010 09:45:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=akNsjGaYfpOI8xypSR1TMNv1QGyiSzHD1m1POX4uRBs=; b=VLVpiKpR2DOnIs3zXwfva+HhctlIuO++EzVjZVUMtRCOEpC/wA/NXcyc8s9ZGecrCK ahlGqaQRZO72Ck7QoKi/9ihENgmuQNvMBxVbWl9OpWzmfBOs0X3+ERr73pRNY7JLDXBi B+CT8jAixBWhZjsLQiKJrx/0lvPMe1jrPOK3M= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=HMqxenDk/H18mK40IB55tubKcDc0KsAb5VWe/f23c35Fveg4kPDfWlQWy58LLig4ca ehS6K1lbmSTNjeTPwR/KL2H2NIKqk7PjmoRAJI/P68XgQh6e7cAw6bgORLCxKS0IZqzu WD/AM/yWQBbMIP95N82AUaZnoXLYdbKQFr2y4= MIME-Version: 1.0 Received: by 10.224.53.203 with SMTP id n11mr3894267qag.321.1285951544645; Fri, 01 Oct 2010 09:45:44 -0700 (PDT) Received: by 10.229.241.2 with HTTP; Fri, 1 Oct 2010 09:45:44 -0700 (PDT) In-Reply-To: References: Date: Fri, 1 Oct 2010 18:45:44 +0200 Message-ID: To: Adam Harvey Cc: PHP internals Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Expose compare_function() to userspace From: hannes.magnusson@gmail.com (Hannes Magnusson) On Thu, Sep 30, 2010 at 16: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) { > =A0return -1; > } > elseif ($a > $b) { > =A0return 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