Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68207 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 33139 invoked from network); 19 Jul 2013 17:08:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jul 2013 17:08:15 -0000 Authentication-Results: pb1.pair.com header.from=petercowburn@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=petercowburn@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.219.44 as permitted sender) X-PHP-List-Original-Sender: petercowburn@gmail.com X-Host-Fingerprint: 209.85.219.44 mail-oa0-f44.google.com Received: from [209.85.219.44] ([209.85.219.44:57162] helo=mail-oa0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E2/4A-13120-D7279E15 for ; Fri, 19 Jul 2013 13:08:14 -0400 Received: by mail-oa0-f44.google.com with SMTP id l10so6462732oag.3 for ; Fri, 19 Jul 2013 10:08:11 -0700 (PDT) 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=HH2T8KXWIw6jhvOIdSVFJG0P5O9sP/k23HrKAulSSbU=; b=LqYVyUyJZFFzC9CjDqfO82MnaeLMokOAo0mmUmt3FXVMfNqHEZQKV1YlWYQ70CKfU+ JiNLdVm/raPwiiroVsw3Dig96FCtH0cpHqdrQeJYwN9NOf0eLUWAC9rjVxIe1CIVtH+8 gR2JJvEKit1QXAR965ZUAJxW6VOqVLPvbWTIMo4Qni2k8qdKxTBrD7E8FM5pwgehHrbk 6Y7YKHdVkM47QKzDq0ZaNUxtgASmW+UwINye+V5sib7cWNyPGX91QNQa3cS8kvSOsg4t tHCQS0/VPAOGyNTvqr3eaoNjloQy5VKbTnJ48mhAWIV4jGlAa0UgK5Bt9wciHeqZuzf/ ONDg== X-Received: by 10.182.120.196 with SMTP id le4mr13003281obb.57.1374253691182; Fri, 19 Jul 2013 10:08:11 -0700 (PDT) MIME-Version: 1.0 Received: by 10.76.142.231 with HTTP; Fri, 19 Jul 2013 10:07:30 -0700 (PDT) In-Reply-To: References: Date: Fri, 19 Jul 2013 18:07:30 +0100 Message-ID: To: Daniel Lowrey Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=089e013a282c18255c04e1e05f9c Subject: Re: [PHP-DEV] Language constructs and callability From: petercowburn@gmail.com (Peter Cowburn) --089e013a282c18255c04e1e05f9c Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 19 July 2013 17:36, Daniel Lowrey wrote: > I have a simple question about the callability of language constructs and > whether or not that's something that might change in the future. Consider= : > > 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` are > 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 nice > to avoid the hassle. So my question is ... > > How deeply ingrained into the engine is this behavior? Is there any chanc= e > of language constructs ever passing the tests for callability or is that > just a pipe dream that's not worth the implementation effort? > --089e013a282c18255c04e1e05f9c--