Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:72365 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 49824 invoked from network); 7 Feb 2014 07:09:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Feb 2014 07:09:57 -0000 Authentication-Results: pb1.pair.com header.from=bof@bof.de; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=bof@bof.de; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain bof.de designates 80.242.145.70 as permitted sender) X-PHP-List-Original-Sender: bof@bof.de X-Host-Fingerprint: 80.242.145.70 mars.intermailgate.com Received: from [80.242.145.70] ([80.242.145.70:55674] helo=mars.intermailgate.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C4/22-34013-4C684F25 for ; Fri, 07 Feb 2014 02:09:56 -0500 Received: (qmail 3429 invoked by uid 1009); 7 Feb 2014 08:09:53 +0100 Received: from 209.85.216.171 by mars (envelope-from , uid 89) with qmail-scanner-1.25-st-qms (clamdscan: 0.96.2/18446. spamassassin: 3.3.1. perlscan: 1.25-st-qms. Clear:RC:1(209.85.216.171):. Processed in 0.062902 secs); 07 Feb 2014 07:09:53 -0000 X-Antivirus-MYDOMAIN-Mail-From: bof@bof.de via mars X-Antivirus-MYDOMAIN: 1.25-st-qms (Clear:RC:1(209.85.216.171):. Processed in 0.062902 secs Process 3415) Received: from mail-qc0-f171.google.com (gmail@bof.de@209.85.216.171) by mars.intermailgate.com with RC4-SHA encrypted SMTP; 7 Feb 2014 08:09:53 +0100 Received: by mail-qc0-f171.google.com with SMTP id n7so5190922qcx.2 for ; Thu, 06 Feb 2014 23:09:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=tmQRWJqecHM6GDd/CLPzr3POhFuj4aRSzaj3/hVLC7k=; b=Y5cTfoT0J7Njlb9Jc/+kZsJJUq81Nf8SlxmMPRE3FOBtDthZSut6biH9yrE0NGo1oa sDe+gBSCd7SI5tG01t+u8nwUGyznFVJg0MozAa3QGM+OaNXxd51hXGaKhMzXNKBhHvRV A3E8O75Ek6lirmHITKciXx60iyPY2FtZq2Lc9rvv+nzZZwq/48PplEefC4eJQfmoIfFh x5Zs5CrcO7vNAjBhsKqkGh8aJH65X3YPDZQpAuoPCR5PHH6S6DNYAqEaD6N2v1EEBx9r QX8TIIMN6e3vs6LVHEFUVbZxk0JX3sHnCR0/LAWO9bEjMYMhbv86PybQpm8s/2c+V1ZY Zdpw== MIME-Version: 1.0 X-Received: by 10.140.30.66 with SMTP id c60mr17809120qgc.13.1391756991787; Thu, 06 Feb 2014 23:09:51 -0800 (PST) Received: by 10.140.41.208 with HTTP; Thu, 6 Feb 2014 23:09:51 -0800 (PST) Received: by 10.140.41.208 with HTTP; Thu, 6 Feb 2014 23:09:51 -0800 (PST) In-Reply-To: References: Date: Fri, 7 Feb 2014 08:09:51 +0100 Message-ID: To: Tjerk Anne Meesters Cc: internals , Yasuo Ohgaki Content-Type: multipart/alternative; boundary=001a113a09e81bf96004f1cbad13 Subject: Re: [PHP-DEV] [discussion] add array_usearch() From: bof@bof.de (Patrick Schaaf) --001a113a09e81bf96004f1cbad13 Content-Type: text/plain; charset=ISO-8859-1 Hi, some thoughts on your discussion: Am 07.02.2014 07:55 schrieb "Tjerk Meesters" : > > That was my first attempt actually; if the first argument is a closure, use > that as the search callback. A few problems with that: > 1) You can't use other types of callback, e.g. string or array. For that (and possibly other uses), it would be good to have a cast-to-closure: $foo = (Closure) 'is_numeric'; $bar = (Closure) [ $that, 'method' ]; That might sometimes even save some work, when the implementation attempts to extract the signature of the thing that is to be cast to make a proper signature for the generated closure. If the callable is then used several times later (callback in a loop) the callable-as-array-or-string-lookup would no longer sit in the middle of the loop. > 2) [bc] You can't search through an array of closures. That's not good. Could be worked around by using a closure that compares to the needle closure, but it would still be a BC break. Code that might be affected would be some kind of registry for lists of callbacks that, upon insert, wants to check that the thing to be inserted isn't there already. I wrote something like that two weeks ago, incidentally :) In the long run, using an is-closure (not is-callable) vs. is-string branch in various callback-taking functions, would make for cleaner code, compared to sprinkling bitmask flag arguments with a DO_IT_CALLBACK_STYLE flag. best regards Patrick --001a113a09e81bf96004f1cbad13--