Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68765 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 18574 invoked from network); 30 Aug 2013 22:57:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Aug 2013 22:57:47 -0000 Authentication-Results: pb1.pair.com smtp.mail=bobwei9@hotmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=bobwei9@hotmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain hotmail.com designates 65.55.111.113 as permitted sender) X-PHP-List-Original-Sender: bobwei9@hotmail.com X-Host-Fingerprint: 65.55.111.113 blu0-omc2-s38.blu0.hotmail.com Windows 2000 SP4, XP SP1 Received: from [65.55.111.113] ([65.55.111.113:45426] helo=blu0-omc2-s38.blu0.hotmail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AD/73-00443-96321225 for ; Fri, 30 Aug 2013 18:57:46 -0400 Received: from BLU0-SMTP411 ([65.55.111.73]) by blu0-omc2-s38.blu0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Fri, 30 Aug 2013 15:57:43 -0700 X-TMN: [yqb1voqckllYPTM43v0pV/YQplTaicg7] X-Originating-Email: [bobwei9@hotmail.com] Message-ID: Received: from [192.168.178.42] ([87.240.210.93]) by BLU0-SMTP411.phx.gbl over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Fri, 30 Aug 2013 15:57:39 -0700 Content-Type: text/plain; charset="iso-8859-1" MIME-Version: 1.0 (Mac OS X Mail 6.5 \(1508\)) In-Reply-To: Date: Sat, 31 Aug 2013 00:57:37 +0200 CC: Developers List PHP Mailing Content-Transfer-Encoding: quoted-printable References: <5220CEDE.8080600@sugarcrm.com> <5220DA50.9020306@sugarcrm.com> <522113B1.8000605@sugarcrm.com> To: Lazare Inepologlou , Malyshev Stas X-Mailer: Apple Mail (2.1508) X-OriginalArrivalTime: 30 Aug 2013 22:57:39.0967 (UTC) FILETIME=[53E7C0F0:01CEA5D4] Subject: Re: [PHP-DEV] [RFC] Argument unpacking From: bobwei9@hotmail.com (Bob Weinand) Hi! Am 31.8.2013 um 00:27 schrieb Lazare Inepologlou : > 2013/8/30 Stas Malyshev >=20 >>> don't see a reason why one should explicitly disallow doing multiple >>> unpacks. >>=20 >> Because it makes very hard to understand what's going on and makes no >> sense semantically. >>=20 >>> As you can see, here two arguments are unpacked in one call. >>=20 >> This is very special use case to be hidden in library functions, I = don't >> think we need to have language syntax specially directed at that, at = the >> cost of making it overall more complex and hard to understand. I can = see >> what "add all those params at the end" syntax mean. However having >> something like ($a, ...$b, $c, ...$d, $e, $f, $g, ...$h) I have no = idea >> what's going on at all and what is sent where. >>=20 >>=20 > I agree with Stas here. If an argument comes after an unpacked array, = its > position is not certain until runtime. This makes life difficult for = static > analysis tools, which is one of the reasons for introducing the new = syntax. The alternative is for users to use what we have now: = call_user_func_array with some array_merge, which makes it as difficult for static analysis = as the new syntax does. This really is a non-argument. And should we really restrict the user's code with some arbitrary = limits? It just makes the user use some really ugly hacks nobody wants to see. > Even in the use case of Nikita, the two arguments to be unpacked come > without any standard arguments between or after them. >=20 > I suggest that argument unpacking should be limited to the last = arguments > only. An example where it really would make sense is: function long ($arg, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7, $string) = { // do something with your arguments } // just instead of copying the seven parameters; increases readability // and don't argue this would be badly statically analyzable - it is, = but this isn't // the point. I want to show that people may find here some use case. function short (...$args) { if (count($args)) return long(...$args, "some value"); } > Lazare Inepologlou > Ing=E9nieur Logiciel >=20 >=20 >=20 > -- >> Stanislav Malyshev, Software Architect >> SugarCRM: http://www.sugarcrm.com/ >> (408)454-6900 ext. 227 I finally am in favor of the proposal, because it allows removing a lot = of ugly call_user_func_array calls which aren't really well readable. (and = naturally because it allows passing the variadic parameters if that rfc will be = accepted) And I think you are really arguing about non-issues. Example: Multiple uses of unpacking syntax makes sense when you call a function with a variadic parameter: function variadic (...$args) { // do something }=20 variadic(...$array1, ...$array2); Bob Weinand