Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88607 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 18634 invoked from network); 1 Oct 2015 15:16:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Oct 2015 15:16:12 -0000 Authentication-Results: pb1.pair.com header.from=derokorian@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=derokorian@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.172 as permitted sender) X-PHP-List-Original-Sender: derokorian@gmail.com X-Host-Fingerprint: 209.85.212.172 mail-wi0-f172.google.com Received: from [209.85.212.172] ([209.85.212.172:35388] helo=mail-wi0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E8/C7-04700-B3E4D065 for ; Thu, 01 Oct 2015 11:16:12 -0400 Received: by wicge5 with SMTP id ge5so34835927wic.0 for ; Thu, 01 Oct 2015 08:16:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=lWT2dcyi8uBmQC7XwcimcBr/tTEz2ndYCxxDyriqnAI=; b=tJCQCYbAfvcOpUj8/5SpcX/vYkD0Ol6ALmzcSOmrBnzf2rVZvaUzMzycIF5fNlAYAH 0jqGChUySiNDgsO2KUD94Q5RMmwOQXWyIJRIDYeSGBkKB3fQuvEa2aMOavQX/qvPPAnf C2evjyI983krx6ytnJCWzEzQ9I6FymWyZWiqbvIsNgstNJ0BJsFX8kR9L48Kac6OMDIZ jGoEgdlWY0dFgqymReNEkDMm4KO+wxQXBk2vhB9UFyGjZumSKipOiXbnRBCAY1AXBx4S TTYhIq1agUOz6Pg121Wm6GoWD2x3lgr7cN4Gcu6/zblf9rgQCFOeAwmtBuchRVaPRksf 3zOg== MIME-Version: 1.0 X-Received: by 10.194.104.200 with SMTP id gg8mr12272675wjb.144.1443712568847; Thu, 01 Oct 2015 08:16:08 -0700 (PDT) Received: by 10.28.143.137 with HTTP; Thu, 1 Oct 2015 08:16:08 -0700 (PDT) In-Reply-To: References: <5606D0EB.3060106@gmail.com> <560D0F94.8060009@gmail.com> <560D282F.6060202@gmail.com> Date: Thu, 1 Oct 2015 09:16:08 -0600 Message-ID: To: Nikita Nefedov Cc: "internals@lists.php.net" , "rowan.collins@gmail.com" Content-Type: multipart/alternative; boundary=089e010d8212d2f50105210c8635 Subject: Re: [PHP-DEV] Arrow function expressions in PHP From: derokorian@gmail.com (Ryan Pallas) --089e010d8212d2f50105210c8635 Content-Type: text/plain; charset=UTF-8 On Thu, Oct 1, 2015 at 8:58 AM, Nikita Nefedov wrote: > > I don't think there was a dozen of different ideas, I could only find > those about `lambda(arg-list; use-list; expression)` and variations of it > with different keywords and different return-type syntax. > I do understand that this is quite subjective, but neither this syntax nor > `fn(arg-list; use-list) expression` look obvious and easily readable to me. > It doesn't look obvious because its new syntax. The first time I saw a for(var; bool; expr) I was totally confused, because I had only seen for var in range. But you know what? I looked at the docs and then knew how it worked, not that hard. > And one thing that makes auto capture much better choice than explicit > capture (as it've been said a couple of times already) is partial > application: > > $mul = fn($x) => fn($y) => fn($z) => $x * $y * $z; > > Looks simpler than: > > $mul = fn($x) => fn($y; $x) => fn($z; $x, $y) => $x * $y * $z; > > Yes it looks simpler, but if this is going to continue being the argument for auto-capturing can we at least get a real world example? I have never once in the wild seen a lambda that returns a lambda that returns a lambda, all using variables from the previous lamba(s). I'm fairly certain no one will invoke the overhead of a function call 3 times just to multiply 3 numbers together. Please give me a valid example if you want me to believe this to be a valid argument. There is no way in php that I know of to get access to a parent's scope, unless explicitly used which is only available on lambda/closures. Therefore, automatic closing of the variables is very much against the scoping rules of the language. It is totally unexpected for someone who has been using the language for many years. --089e010d8212d2f50105210c8635--