Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68208 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34563 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 smtp.mail=jelle.zijlstra@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=jelle.zijlstra@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.83.45 as permitted sender) X-PHP-List-Original-Sender: jelle.zijlstra@gmail.com X-Host-Fingerprint: 74.125.83.45 mail-ee0-f45.google.com Received: from [74.125.83.45] ([74.125.83.45:39805] helo=mail-ee0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D6/9A-13120-C4379E15 for ; Fri, 19 Jul 2013 13:11:40 -0400 Received: by mail-ee0-f45.google.com with SMTP id c1so2523307eek.4 for ; Fri, 19 Jul 2013 10:11:37 -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=cXGVQpro8fqylHozBeslUWHrSz4cSiKxO0khzzFZ+iE=; b=Ueg4KfBJIn8FRbTQsfyYT6kJdl61gML56Byb2igSfDH275Ov7sbJ0MsPbGTqblcBMQ +DBL2MsWlm2tJ6L0dTeMIb/IndbHbt1SbL8Gj7nKWezHnTfVdPyehjBTnl3YwlBxm62B gK0pHaiEIb8Ai34xAsdWan03bLE9evYAKljb8lMFJRqO28YRkutrVHB+Al3qqJUbLiKx 6WFZzR4+m4k9zTT+HSYJx3vPmtqmnpExkTPA0z29BEnNjEwb47CN/ia9GjeFHMyOnHPr /4qq/5H0JFb7yhKgsdT8TjZA1fX7BCoF2nfx5p5FOKSPtNyWVfHapANxs5sGHqjgRvr7 C/TA== MIME-Version: 1.0 X-Received: by 10.14.110.9 with SMTP id t9mr16791242eeg.115.1374253897672; Fri, 19 Jul 2013 10:11:37 -0700 (PDT) Received: by 10.14.148.140 with HTTP; Fri, 19 Jul 2013 10:11:37 -0700 (PDT) In-Reply-To: References: Date: Fri, 19 Jul 2013 19:11:37 +0200 Message-ID: To: Peter Cowburn Cc: Daniel Lowrey , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=089e0160cbb467141c04e1e06bbb Subject: Re: [PHP-DEV] Language constructs and callability From: jelle.zijlstra@gmail.com (Jelle Zijlstra) --089e0160cbb467141c04e1e06bbb Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable 2013/7/19 Peter Cowburn > On 19 July 2013 17:36, Daniel Lowrey wrote: > > > I have a simple question about the callability of language constructs a= nd > > 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` a= re > > language constructs and not functions. I can see some potential benefit= s > > for working around this. For example, say I want to filter only the NUL= L > > 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'); > > That would do the opposite of what you want. > > > > > Of course, this limitation is trivial to work around with a userland > > callback to check for the explicit NULL equivalency, but it would be ni= ce > > to avoid the hassle. So my question is ... > > > > How deeply ingrained into the engine is this behavior? Is there any > chance > > of language constructs ever passing the tests for callability or is tha= t > > just a pipe dream that's not worth the implementation effort? > > > --089e0160cbb467141c04e1e06bbb--