Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91127 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 83469 invoked from network); 8 Feb 2016 17:47:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Feb 2016 17:47:18 -0000 Authentication-Results: pb1.pair.com smtp.mail=kinncj@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=kinncj@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.45 as permitted sender) X-PHP-List-Original-Sender: kinncj@gmail.com X-Host-Fingerprint: 209.85.213.45 mail-vk0-f45.google.com Received: from [209.85.213.45] ([209.85.213.45:36352] helo=mail-vk0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 73/67-36326-4A4D8B65 for ; Mon, 08 Feb 2016 12:47:17 -0500 Received: by mail-vk0-f45.google.com with SMTP id c3so53876347vkb.3 for ; Mon, 08 Feb 2016 09:47:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=Jta0EioCdoQtg4Xp04UCZuu05S1nVlDxI6mxb0PwQG8=; b=cGQpKgMJNexhcSKRPuVEan6Ksuyi+oZ8TLCkd2ehJDsJ8ARlsdebngD7S5FR0W9Dl3 bjj2vgfqdAtedc8OPDowyZRZSe88J5GHvVEmqHZVk6YNYi6BBycdZVQHcCgYCPuWMUEJ 1WtdrpfLnkhtPVAxCyJkGdnXRO6QQNUABHiMtKpV0gJDwvriGm0LVGwLAjoNj3fiD8U6 /jwGIu09yl1GNSoGESOMh2N0qhagBGGqQsLcNiC4Rylu7mQUQtK0EVqCq3JpXLILHM0v k30/AnHFHJwLsqzTbEqD1tvCE+ad6ma6IJm68vlOG2xtzcDBgKMZJ2diAmOEI2hDi72t FONQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=Jta0EioCdoQtg4Xp04UCZuu05S1nVlDxI6mxb0PwQG8=; b=mfBRanlwi+sKZNs67GckJXyM+ksFhvgS52AEjff1sSPeUmpDrEs3QGY5Hcsq6T4/hJ Qa8OW0xJluiyPfwsDtllCJccNF/s48Fu5AOcWG/K9s4fMkHFCvRm219puCo/AEPm7uAd voKtPTpk2ylNE3NukcTZtb8qM+yaPtWRotGP8quW6gi5LNGzUY6km6K79tFtlCCGpLfb RUXhV9VIW1ftqb3424YnQatSeWAdg9BRTEz5dBZborG0ekavxmjso5CbzSMpWZcynGmr KOC80GR7DIiG9TgUpSqG4qeydreFvGDHQseslK3DTUlUOA400iM90zByw5uHP3V/NjH4 fmKw== X-Gm-Message-State: AG10YOQa5NPqoflg3yqfIWFlxOmmkrL+H+ueGTaz6SHATzhxaqqZHfyZFgSlKZhPoU3CWfWBJq/WY655NZ+GnA== X-Received: by 10.31.5.134 with SMTP id 128mr20965776vkf.29.1454953633344; Mon, 08 Feb 2016 09:47:13 -0800 (PST) MIME-Version: 1.0 Received: by 10.31.52.23 with HTTP; Mon, 8 Feb 2016 09:46:53 -0800 (PST) In-Reply-To: <56B8C492.2060800@gmail.com> References: <56B8C492.2060800@gmail.com> Date: Mon, 8 Feb 2016 12:46:53 -0500 Message-ID: To: Rowan Collins Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=001a114415f47b1c68052b45ca8f Subject: Re: [PHP-DEV] Proposal for a new array function From: kinncj@gmail.com (=?UTF-8?B?S2lubiBKdWxpw6Nv?=) --001a114415f47b1c68052b45ca8f Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Mon, Feb 8, 2016 at 11:38 AM, Rowan Collins wrote: > Kinn Juli=C3=A3o wrote on 08/02/2016 16:05: > >> That's the nice thing about userland... you are giving them ability to >> implement what they want! >> `array_filter([...], 'is_int', ARRAY_FILTER_USE_KEY)` does the job as th= e >> others... don't think having a new function would prevent this. >> > > It does the job, but it is much less efficient in some cases than the > foreach and return false case, as it must examine every element; it also > has unnecessary memory overhead, creating a filtered list which exists on= ly > to be counted and thrown away; and an internal implementation could be > optimised even further by exploiting the way the engine stores the array > internally. > How does `array_filter([...], 'is_int', ARRAY_FILTER_USE_KEY)` add that *much* overhead? And if that's the case, instead of introducing a 99999 array function into the core, why not just create a new Object then? $list =3D list('foo','bar'); // I know it's a reserved token, don't have ti= me to find a better synonym. it's just a sample $list[2] =3D 'baz'; var_dump($list); string(1) "foo" string(1) "bar" string(1) "baz" $list['a'] =3D 'foobar'; // Fatal error. > > PHP is at this stage expressive enough that a large number of core > functions could be rewritten in multiple ways using other core functions, > but that doesn't automatically rule out adding more functions to core whe= re > it is useful to do so. PHP is at a stage where we can add support to a better structure and objects support... we don't need a function to check if the keys are integer, we need an object that only supports integer as keys, or even a generic key... Would rather have `Map` than `has_numeric_keys` > > > Regards, > -- > Rowan Collins > [IMSoP] > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --=20 *--* *Kinn Coelho Juli=C3=A3o* *Toronto - ON/Canada* --001a114415f47b1c68052b45ca8f--