Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68209 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34641 invoked from network); 19 Jul 2013 17:11:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jul 2013 17:11:41 -0000 Authentication-Results: pb1.pair.com header.from=rdlowrey@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rdlowrey@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.181 as permitted sender) X-PHP-List-Original-Sender: rdlowrey@gmail.com X-Host-Fingerprint: 209.85.223.181 mail-ie0-f181.google.com Received: from [209.85.223.181] ([209.85.223.181:58378] helo=mail-ie0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E6/9A-13120-C4379E15 for ; Fri, 19 Jul 2013 13:11:41 -0400 Received: by mail-ie0-f181.google.com with SMTP id x12so9945029ief.12 for ; Fri, 19 Jul 2013 10:11:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=oiHvUQKwE5fE566UQwKSIdXF4WqF8/WCpHfyBSe6wYY=; b=PSQ1bigG2uij1ZK9Eaq1QRonW9RUSR8Dvopbh/wHv4rhjCJB1c23EJGkwFgFbUrX+F bL/23kYmUn+28+8061Teo5RISaY4+O/A1nPKzcIoMDof5S/Q5J5SglDTuIka40DGQVL4 kz/f8LIKoz+ruRd58btyA1IjMuFuet5bfDXfOkA64Q7m626KilM0h9J3G7RJ78o/Tyk8 DPU0DZD1AvPbo/ipcOsO6P6rYjw47waMqNkNWXzuPTKjBZ56biQJIqdQb98M5lh3pa5Q tak2kx84W0H2wyQCeIio/FbvS4VlXCEbvjzPuXUOBqDPZgxoWVDsHIfSlWTYQQROXbd2 fOnw== MIME-Version: 1.0 X-Received: by 10.43.87.136 with SMTP id aw8mr11141380icc.77.1374253898418; Fri, 19 Jul 2013 10:11:38 -0700 (PDT) Received: by 10.50.7.1 with HTTP; Fri, 19 Jul 2013 10:11:38 -0700 (PDT) In-Reply-To: References: Date: Fri, 19 Jul 2013 13:11:38 -0400 Message-ID: To: Peter Cowburn Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a11c1f84072510f04e1e06b9a Subject: Re: [PHP-DEV] Language constructs and callability From: rdlowrey@gmail.com (Daniel Lowrey) --001a11c1f84072510f04e1e06b9a Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable > array_filter([=85], 'is_null'); Doesn't work -- `is_null` would return TRUE leaving a result of [NULL] after the array_filter operation. That's the diametric opposite of what my example code looks to do. On Fri, Jul 19, 2013 at 1:07 PM, Peter Cowburn wrot= e: > > > > On 19 July 2013 17:36, Daniel Lowrey wrote: > >> I have a simple question about the callability of language constructs an= d >> whether or not that's something that might change in the future. Conside= r: >> >> var_dump(is_callable('echo')); // bool(false) >> var_dump(call_user_func('echo', 'foo')); // E_WARNING >> echo('foo'); // foo >> >> var_dump(is_callable('isset')); // bool(false) >> var_dump(isset(1)); // E_ERROR >> >> Obviously this behavior arises because tokens like `echo` and `isset` ar= e >> language constructs and not functions. I can see some potential benefits >> for working around this. For example, say I want to filter only the NULL >> elements from an array but keep the other "falsy" values. Recognizing >> `isset` as callable would allow me to do this: >> >> var_dump(array_filter([0, FALSE, NULL], 'isset')); // [0, FALSE] >> > > array_filter([=85], 'is_null'); > > >> >> Of course, this limitation is trivial to work around with a userland >> callback to check for the explicit NULL equivalency, but it would be nic= e >> to avoid the hassle. So my question is ... >> >> How deeply ingrained into the engine is this behavior? Is there any chan= ce >> of language constructs ever passing the tests for callability or is that >> just a pipe dream that's not worth the implementation effort? >> > > --001a11c1f84072510f04e1e06b9a--