Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60117 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 19487 invoked from network); 17 Apr 2012 22:10:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Apr 2012 22:10:40 -0000 Authentication-Results: pb1.pair.com header.from=neufeind@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=neufeind@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 91.184.32.3 as permitted sender) X-PHP-List-Original-Sender: neufeind@php.net X-Host-Fingerprint: 91.184.32.3 mail.speedpartner.de Linux 2.5 (sometimes 2.4) (4) Received: from [91.184.32.3] ([91.184.32.3:39702] helo=mail.speedpartner.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EA/86-21594-E5AED8F4 for ; Tue, 17 Apr 2012 18:10:39 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.speedpartner.de (Postfix) with ESMTP id EAF73B3DAF for ; Wed, 18 Apr 2012 00:10:35 +0200 (CEST) Received: from mail.speedpartner.de ([127.0.0.1]) by localhost (mail.speedpartner.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ys0urStI-hGX for ; Wed, 18 Apr 2012 00:10:35 +0200 (CEST) Received: from collab.speedpartner.de (collab.speedpartner.de [91.184.32.10]) by mail.speedpartner.de (Postfix) with ESMTP id D6689B3DAC for ; Wed, 18 Apr 2012 00:10:35 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by collab.speedpartner.de (Postfix) with ESMTP id 91C3CCA86BF for ; Wed, 18 Apr 2012 00:10:33 +0200 (CEST) X-Virus-Scanned: amavisd-new at collab.speedpartner.de Received: from collab.speedpartner.de ([127.0.0.1]) by localhost (collab.speedpartner.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WOvR2XTWoPNp for ; Wed, 18 Apr 2012 00:10:31 +0200 (CEST) Received: from [192.168.4.20] (ip-62-143-28-82.unitymediagroup.de [62.143.28.82]) by collab.speedpartner.de (Postfix) with ESMTPSA id 5FE05CA17FB for ; Wed, 18 Apr 2012 00:10:31 +0200 (CEST) Message-ID: <4F8DEA47.9060706@php.net> Date: Wed, 18 Apr 2012 00:10:15 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120329 Thunderbird/11.0.1 MIME-Version: 1.0 To: php-dev References: <4F8DE877.1010600@php.net> In-Reply-To: <4F8DE877.1010600@php.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Variable-length args by reference From: neufeind@php.net (Stefan Neufeind) On 04/18/2012 12:02 AM, Stefan Neufeind wrote: > Hi, > > the topic of variable argument-lists for functions in connection with > getting the parameters by reference came up. This is currently not > possible with func_get_args(), though a "hack" with debug_backtrace() is > possible. > > How would you think about extending func_get_args() and func_get_arg() > to allow for: > > $args = func_get_args(FUNC_GET_ARGS_BY_REFERENCE); > $arg0 = func_get_arg (0, FUNC_GET_ARGS_BY_REFERENCE); > > (default would be FUNC_GET_ARGS_BY_COPY) > > > Currently only the following "hack" works: > > function calc() > { > $d = debug_backtrace(); > $args = $d[0]['args']; > $args[0] *= 2; > $args[1] *= 2; > } > > $a = 5; > $b = 7; > var_dump ($a, $b); > calc(&$a, &$b); > var_dump ($a, $b); Hmm, that example also only works because of the call-time pass-by-reference? *sigh* Sorry, I forgot those ampersands in the call to calc(). Doesn't work without. I hope the idea is clear though. Any chance we might make this possible through func_get_args()? Regards, Stefan