Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68640 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 2423 invoked from network); 28 Aug 2013 16:18:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Aug 2013 16:18:39 -0000 Authentication-Results: pb1.pair.com smtp.mail=linepogl@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=linepogl@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.219.44 as permitted sender) X-PHP-List-Original-Sender: linepogl@gmail.com X-Host-Fingerprint: 209.85.219.44 mail-oa0-f44.google.com Received: from [209.85.219.44] ([209.85.219.44:39860] helo=mail-oa0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 20/A0-33204-ED22E125 for ; Wed, 28 Aug 2013 12:18:38 -0400 Received: by mail-oa0-f44.google.com with SMTP id l17so3444589oag.17 for ; Wed, 28 Aug 2013 09:18:36 -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=5PO1pce2neTPOS8PMVvVQtZ25p25lW0FClfuvIqlGj0=; b=NXjldEoksOo/tAwPx8dPw/VmvN0qSW0Vm2lfuCf8DpBfL1JAWDKIxAGSbAmWasnm7u NRLLyjbr6ClHhsju0aIPzgQcuJLnH5CL5dO4bCyDpLt89U6iBkyBGOL30Qieis3m9109 RWLsY5U1KR60xfspDcfspAy2BYL5sb2jcrYP8ssIq4PXWw21MlkdiwFxdMBFLQQAxG1m iFd4qF2LZgi2M4YKwHfRE+HU+nfirKg71Rd5j7y7l80eFGKMMmtDDo5ahcbrsVzhzxDO UOXHCAf/tgND2bKA7h+Il8ZPtjSCY6MigfR00i4jeoXLhwzHClMSa4nQAVzpeaDYuI7B 83zA== X-Received: by 10.182.119.229 with SMTP id kx5mr23928055obb.23.1377706715889; Wed, 28 Aug 2013 09:18:35 -0700 (PDT) MIME-Version: 1.0 Received: by 10.76.100.6 with HTTP; Wed, 28 Aug 2013 09:18:14 -0700 (PDT) In-Reply-To: References: Date: Wed, 28 Aug 2013 18:18:14 +0200 Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: multipart/alternative; boundary=001a11c2e352682f9404e504577e Subject: Re: [PHP-DEV] [RFC] Syntax for variadic functions From: linepogl@gmail.com (Lazare Inepologlou) --001a11c2e352682f9404e504577e Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 2013/8/28 Nikita Popov > Hi internals! > > I'd like to propose an RFC, which adds dedicated syntax for variadic > functions: > > https://wiki.php.net/rfc/variadics > > Basically this allows declaring variadics directly in the function > signature, rather than fetching the arguments using func_get_args(). > Example: > > public function query($query, ...$params) { /* ... */ } > > What are your thoughts on this? > > +1, primarily because it makes the code self-documented. However, I would like to hilight one shortcoming of variadic functions (both with the old and with the proposed syntax): There is no way to call a variadic function unless all the arguments are hard-coded. I am extenting the example of the RFC: class MySQL implements DB { public function query($query, ...$params) { // ... } public function query_and_log($query, ...$params) { // this will not work: $result =3D $this->query( $query, $params ); log( $query ); return $result; } } Not only this does not work, but there is no way to make it work without modifying the original function. Would it be possible to extend the RFC with new syntax that could cover cases like that as well? Maybe something like that: $result =3D $this->query( $query, ...$params ); Other than that, the RFC is very welcome. Lazare INEPOLOGLOU Ing=C3=A9nieur Logiciel > Thanks, > Nikita > --001a11c2e352682f9404e504577e--