Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68210 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37340 invoked from network); 19 Jul 2013 17:14:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jul 2013 17:14:14 -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.52 as permitted sender) X-PHP-List-Original-Sender: petercowburn@gmail.com X-Host-Fingerprint: 209.85.219.52 mail-oa0-f52.google.com Received: from [209.85.219.52] ([209.85.219.52:62038] helo=mail-oa0-f52.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1F/3B-13120-5E379E15 for ; Fri, 19 Jul 2013 13:14:13 -0400 Received: by mail-oa0-f52.google.com with SMTP id g12so6297579oah.39 for ; Fri, 19 Jul 2013 10:14:10 -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=F5HDzKVcbKLEiUu0P27cyRvaU1eJwyRcXhGM7BczdVM=; b=uJg4WqqFg4xuIR+ag0E6G/p4Yp+stpgToomfM+2Xm3VgG6+PA0lnrpQ1mdZ1vZpyAG l0/Pc5haVq2uEtZxTHvExAtpqu/coh17CCELwTjAGFlo4oueaRIrdXzeRiH4/4LihF7M vGwCGCKbQZu32ZLerdyEMsl4/fuWJ+23jktgfz+/Lr31RjtfP35WH2uwq9/sLtY+6t2r +21CCm+C0n+v4wZGDcdoXlyYfDbOqxQueTHkgSFDKcncXmwjwv+3j5/5ZfAOKL3GL7Lb 56nMelf+NIrGdLM1bc2nlx0DcClFutKy46ah75NwIzHGUe/dm6edfojJuE5SZeOM5U8+ DdLw== X-Received: by 10.60.37.233 with SMTP id b9mr18499938oek.61.1374254050255; Fri, 19 Jul 2013 10:14:10 -0700 (PDT) MIME-Version: 1.0 Received: by 10.76.142.231 with HTTP; Fri, 19 Jul 2013 10:13:30 -0700 (PDT) In-Reply-To: References: Date: Fri, 19 Jul 2013 18:13:30 +0100 Message-ID: To: Jelle Zijlstra Cc: Daniel Lowrey , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=089e013c6a707f29e304e1e074d4 Subject: Re: [PHP-DEV] Language constructs and callability From: petercowburn@gmail.com (Peter Cowburn) --089e013c6a707f29e304e1e074d4 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 19 July 2013 18:11, Jelle Zijlstra wrote: > > > > 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. > Absolutely (I blame Friday). Still, this is only being suggested because "isset" just happens to do what is needed in this case? Where to other language constructs fit into it? > >> > >> > 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? >> > >> > > --089e013c6a707f29e304e1e074d4--