Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87972 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 9931 invoked from network); 1 Sep 2015 03:47:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Sep 2015 03:47:03 -0000 Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.50 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.220.50 mail-pa0-f50.google.com Received: from [209.85.220.50] ([209.85.220.50:34362] helo=mail-pa0-f50.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 96/D9-39890-6BF15E55 for ; Mon, 31 Aug 2015 23:47:02 -0400 Received: by pabzx8 with SMTP id zx8so161059488pab.1 for ; Mon, 31 Aug 2015 20:46:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-type:content-transfer-encoding; bh=viGMqRj0a3Q97USI2bdoqWVXn9UaLkSlzdcUHTwwGFk=; b=av+20lz2KtOnQObYlkrzcJbJFpUKim2WHjrMJuosvJks/pkWxSHNy3mNmz0fCTUXy3 BbW6xpExtqIScyHFTmRW1it36eTwoAUp6EdnOAr/wi+cccR06MnbOt7hr6uu0K8PHTVD X/WNB9dVN+x/ZrYu+Snd2wKZPkWKEAt1ZcPBIoY3qpDxojJcMUYS9dwc1/z9DtuB/MbU EjPfEKr8EhuoD5MPHiU1rNMEWdV0pxP4+btEBljtMAPEXW4d/Pm34F55BYkp9cAbk+DT mBK5WfockiQH3LGSsNUVJfU1KYFhbmYf//rOG5NiV+cxyV4uDpIwGk9TzlJndqkbmb3s 5S4w== X-Received: by 10.66.156.196 with SMTP id wg4mr43224161pab.65.1441079218302; Mon, 31 Aug 2015 20:46:58 -0700 (PDT) Received: from Stas-Air.local (108-66-6-48.lightspeed.sntcca.sbcglobal.net. [108.66.6.48]) by smtp.gmail.com with ESMTPSA id dh9sm16224896pdb.67.2015.08.31.20.46.57 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 31 Aug 2015 20:46:57 -0700 (PDT) To: Bob Weinand References: <55E4C19F.4060704@gmail.com> <55E4F029.10104@gmail.com> <7BCB36EE-56C8-441F-BF40-954D9FA912A9@lerdorf.com> Cc: "internals@lists.php.net" X-Enigmail-Draft-Status: N1110 Message-ID: <55E51FAA.8030106@gmail.com> Date: Mon, 31 Aug 2015 20:46:50 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] [Discussion] Short Closures From: smalyshev@gmail.com (Stanislav Malyshev) Hi! > Here it is very obvious that we want to import a variable. Especially, I wonder how > $array = array_map(function ($x) use ($y) { return $x + $y; }, $array); > is making such simple applications more readable? And especially, what value does it add here? It is making it more readable by explicitly specifying that we're using function, that this function imports $y from parent scope and returns $x + $y. Of course, a seasoned programmer that has years of experience in functional languages would recognize this pattern, but that's not exactly the main target audience of PHP. And I do not think the argument "you don't have to use it" is a good one for adding language syntax constructs. If it's in the language, you'd have to deal with it, and you'd have to teach other people to deal with it. It's not some function sitting in the extension that may not even be loaded - it's part of language syntax. So if it would encourage write-only code, you'd have to deal with it even if you don't personally create write-only code. -- Stas Malyshev smalyshev@gmail.com