Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68211 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 39455 invoked from network); 19 Jul 2013 17:16:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jul 2013 17:16:59 -0000 Authentication-Results: pb1.pair.com smtp.mail=rdlowrey@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rdlowrey@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.171 as permitted sender) X-PHP-List-Original-Sender: rdlowrey@gmail.com X-Host-Fingerprint: 209.85.223.171 mail-ie0-f171.google.com Received: from [209.85.223.171] ([209.85.223.171:50855] helo=mail-ie0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 77/BB-13120-A8479E15 for ; Fri, 19 Jul 2013 13:16:59 -0400 Received: by mail-ie0-f171.google.com with SMTP id qd12so9951099ieb.30 for ; Fri, 19 Jul 2013 10:16:55 -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=JAXoG51vka2mpwbgdGvEkvB1yE7YTuTmlnL3n3jd9fw=; b=qPSehw471b9QfM0Br8pazE5ygRO9WypwzgLqoEfa6mgtVdc3IOya3cASOUD3f+ka/v E1aPZkSgSFQSBBn0x9hKnC7NFx/fwEeYR5QBjWI8BOQfHAacOkFJcDQ6/rIVmjfuykHq L4wQaXuZgLMdYy9Nj+2AFX1xDcUmIQI0NgKPvb3s3c0ZQrQNTPJmIavXD/XQfUlsWOpB IxrR3C3d6zC11nk1x59+PH9nbkplfqXs00w80DAlVfvN82gSaHaP2zJZHgpVG3XexDT9 n2HKNcfLfrtq2DUSN1XslTeMKA2y92fnOrfLNKzfAsiw4nk0tsxkYMX8SYl0Zhj3ircT OZew== MIME-Version: 1.0 X-Received: by 10.43.99.138 with SMTP id cs10mr11709981icc.105.1374254215654; Fri, 19 Jul 2013 10:16:55 -0700 (PDT) Received: by 10.50.7.1 with HTTP; Fri, 19 Jul 2013 10:16:55 -0700 (PDT) In-Reply-To: References: Date: Fri, 19 Jul 2013 13:16:55 -0400 Message-ID: To: Jelle Zijlstra Cc: Peter Cowburn , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=bcaec5171a7d5af8cd04e1e07e58 Subject: Re: [PHP-DEV] Language constructs and callability From: rdlowrey@gmail.com (Daniel Lowrey) --bcaec5171a7d5af8cd04e1e07e58 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable > Oh yeah, I see your point about is_null but not why it makes any more sense to allow language constructs there. Yeah I don't know if it even does. I'm not even really sure if there's a good example use case for it besides the array_filter/isset combo. My question was really only exploratory in nature. On Fri, Jul 19, 2013 at 1:12 PM, Peter Cowburn wrote: > Oh yeah, I see your point about is_null but not why it makes any more > sense to allow language constructs there. > On Fri, Jul 19, 2013 at 1:11 PM, Jelle Zijlstra w= rote: > > > > 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 >> 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 benefi= ts >> > for working around this. For example, say I want to filter only the NU= LL >> > 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 >> nice >> > 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 th= at >> > just a pipe dream that's not worth the implementation effort? >> > >> > > --bcaec5171a7d5af8cd04e1e07e58--