Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:77856 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 82374 invoked from network); 10 Oct 2014 20:39:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Oct 2014 20:39:58 -0000 Authentication-Results: pb1.pair.com header.from=kris.craig@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=kris.craig@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.45 as permitted sender) X-PHP-List-Original-Sender: kris.craig@gmail.com X-Host-Fingerprint: 209.85.218.45 mail-oi0-f45.google.com Received: from [209.85.218.45] ([209.85.218.45:39715] helo=mail-oi0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7C/21-06615-D1448345 for ; Fri, 10 Oct 2014 16:39:58 -0400 Received: by mail-oi0-f45.google.com with SMTP id i138so8044959oig.32 for ; Fri, 10 Oct 2014 13:39: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=6b6CeT3sSPPMJT09Qyjz5MDTuFmdDoatsnZbTpZykkw=; b=TkzCnI0KJR2b+IAziyFB49J4LDe7kE/8E33zfYc8RDoUUvZ3i9w5l6Fw5hpa+X03hW 8duoDyxoZSqXVYFqQ8O1mrak+OF+wOEqcAyPYK4ApYFW7jfFnBbObwtl4H+1cRQs+gE3 HHUw6Pq67AB0e6fAFcgly+dhGhodw95lFhFtxGw6fh6vhqNvARZwhGSykdfYAYcGQhqU JUi6fg/mC3rEqSt6utkoOHM/p4Osg0cXQ1Xxlao2aQELR/c0Z5HT8/1SIs4tQmqhF0bu bLtSr1Gx3p6TVk/J+vA+AWk076sEAWjZpP6LEj2IaBpH93miO2vAIN7UZqqkQ5GqLyYu cCvg== MIME-Version: 1.0 X-Received: by 10.182.40.234 with SMTP id a10mr6785448obl.8.1412973595146; Fri, 10 Oct 2014 13:39:55 -0700 (PDT) Received: by 10.202.169.201 with HTTP; Fri, 10 Oct 2014 13:39:55 -0700 (PDT) In-Reply-To: <4D642F36-81F2-42DD-876D-78B4B8368214@ajf.me> References: <4D642F36-81F2-42DD-876D-78B4B8368214@ajf.me> Date: Fri, 10 Oct 2014 13:39:55 -0700 Message-ID: To: Andrea Faulds Cc: Marco Pivetta , PHP Internals List Content-Type: multipart/alternative; boundary=001a11c3319e3742d80505178d4f Subject: Re: [PHP-DEV] Deprecation of func_get_args(), call_user_func_array() and related API From: kris.craig@gmail.com (Kris Craig) --001a11c3319e3742d80505178d4f Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Fri, Oct 10, 2014 at 1:34 PM, Andrea Faulds wrote: > > On 10 Oct 2014, at 21:27, Marco Pivetta wrote: > > > While rambling with some code today, I realized that `call_user_func` > > behaves strangely, appearing and disappearing from stack traces dependi= ng > > on versions of PHP. For an example, compare > > http://3v4l.org/fGpIk#vphp7@20140901, http://3v4l.org/fGpIk#v530 and > > http://3v4l.org/fGpIk#vhhvm-301. > > IIRC this is a bug caused by PHP7 eliminating the call to the function > entirely, and instead inserting a normal function call opcode. See: > https://github.com/php/php-src/blob/292421d3a1fcefe88c3017ffdb9f889c39a6c= 8c1/Zend/zend_compile.c#L2777 > > This could possibly be fixed somehow. > > > Additionally, it seems like `call_user_func` and similars are impacting > > performance in some parts of my codebase (event dispatcher logic). > > In PHP 7, due to the function call removal, it should be just the same, > performance-wise, as a normal function call. > > > Therefore, here comes my idea of simply getting rid of `call_user_func`= , > > `call_user_func_array`, `func_get_args`, `func_num_args` and > `func_get_arg`. > > > > My plan for it would be to add a deprecation (notice? not sure about > that) > > in PHP 5.7, and a complete removal of those methods in PHP 7.0. > > > > BC compatibility is easily achieved as variadics ( > > https://wiki.php.net/rfc/variadics) allow for writing cleaner and less > > complex versions: > > =E2=80=9CEasily=E2=80=9D achieved? No. This would break an awful, awful l= ot of existing > PHP code with no gain. There=E2=80=99s no need to deprecate it any time s= oon. The > variadics syntax is merely a nicer alternative. We should not force peopl= e > to rewrite existing code to use it. There is absolutely no need to get ri= d > of func_get_args. > > I would vote against any such proposal, and I hope others on the list > would join me in doing so. > > -- > Andrea Faulds > http://ajf.me/ > > > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > Agreed. The call_user_func() and call_user_func_array() functions are used all over the place. I see absolutely no gain, whatsoever in removing them and forcing developers to write their own userland variants instead. --Kris --001a11c3319e3742d80505178d4f--