Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68767 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 22655 invoked from network); 30 Aug 2013 23:39:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Aug 2013 23:39:23 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@sugarcrm.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@sugarcrm.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain sugarcrm.com designates 108.166.43.115 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 108.166.43.115 smtp115.ord1c.emailsrvr.com Linux 2.6 Received: from [108.166.43.115] ([108.166.43.115:45935] helo=smtp115.ord1c.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 30/44-00443-A2D21225 for ; Fri, 30 Aug 2013 19:39:22 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp7.relay.ord1c.emailsrvr.com (SMTP Server) with ESMTP id 18E7F1B80F6; Fri, 30 Aug 2013 19:39:20 -0400 (EDT) X-Virus-Scanned: OK Received: by smtp7.relay.ord1c.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id 5B4C91B80A2; Fri, 30 Aug 2013 19:39:18 -0400 (EDT) Message-ID: <52212D25.6070707@sugarcrm.com> Date: Fri, 30 Aug 2013 16:39:17 -0700 Organization: SugarCRM User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: Bob Weinand CC: Lazare Inepologlou , Developers List PHP Mailing References: <5220CEDE.8080600@sugarcrm.com> <5220DA50.9020306@sugarcrm.com> <522113B1.8000605@sugarcrm.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Argument unpacking From: smalyshev@sugarcrm.com (Stas Malyshev) Hi! > function short (...$args) { > if (count($args)) > return long(...$args, "some value"); > } This is exactly the problem. Since $args has undefined number of arguments, there's no way to determine where "some value" ends up. Which means it's impossible to understand what's going on here. Now, if we had named arguments, like python had, then using "some value" as a named argument might work (and we'd need to see what to do with named arguments in this case), but as positional argument this just doesn't make much sense beyond some very esoteric things that nobody uses directly, without wrapping libraries (like partially applied functions) - at least in PHP. > 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 > } > > variadic(...$array1, ...$array2); Again, since parameters in PHP are positional, they have meaning depending on position. If you just wanted to pass an array, pass an array, you don't need to use variadic syntax for that. Variadic syntax makes sense only if positions there have meanings and you want to give specific meanings to specific arguments in specific positions. In that case, ...$array1, ...$array2 doesn't work since you can not have meaningful positions. Only case where it works if you do functional operations like partial application, where the meaning of the function is not important but only the fact that it is a function is important. But I don't think we need special syntax to do such things. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227