Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88613 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 33586 invoked from network); 1 Oct 2015 17:12:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Oct 2015 17:12:22 -0000 Authentication-Results: pb1.pair.com header.from=bishop.bettini@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=bishop.bettini@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.179 as permitted sender) X-PHP-List-Original-Sender: bishop.bettini@gmail.com X-Host-Fingerprint: 209.85.212.179 mail-wi0-f179.google.com Received: from [209.85.212.179] ([209.85.212.179:33281] helo=mail-wi0-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2F/61-26330-6796D065 for ; Thu, 01 Oct 2015 13:12:22 -0400 Received: by wiclk2 with SMTP id lk2so311974wic.0 for ; Thu, 01 Oct 2015 10:12:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:sender:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=f1gMXZs7YcTS/WkjqKBbLcUH5EA3WIsDTNRwSZLa8Ew=; b=KerdSQfwMzv7BjHO5vcHzTdPJnme8uk8e3Ai822q5bGJPrzkVHFd/LhZWFMMq1xdln CUtr4vkhQFcuTUaVPij3LJxKkoq9OmG73s8fcfZFo4TuPtmVV8WIBUaNE9CR9HRbNNmp FiRxHfoSGawgpnWV6q5Sbq+BdHsuQZ80MEbbYfXnAtqI8JpfiFbA8aKrnykj2Xdy63dJ C3/AxKVVfvtTFXbwS9EruZAeMA5xcqKEUvIqyTwQGVbnRBYMoepCVhmhD4fPXZhsh1+3 wyPANtVGuuFPsO/y46X2/nvrE7IBoRATJWwT5mXKkG5W67HKv+pWNqF3HeRsM+3aSYs6 4W8A== MIME-Version: 1.0 X-Received: by 10.194.82.198 with SMTP id k6mr11532830wjy.139.1443719539197; Thu, 01 Oct 2015 10:12:19 -0700 (PDT) Reply-To: bishop@php.net Sender: bishop.bettini@gmail.com Received: by 10.194.110.72 with HTTP; Thu, 1 Oct 2015 10:12:19 -0700 (PDT) In-Reply-To: References: <5606D0EB.3060106@gmail.com> <560D0F94.8060009@gmail.com> <560D282F.6060202@gmail.com> Date: Thu, 1 Oct 2015 13:12:19 -0400 X-Google-Sender-Auth: nN0180aYicSfBktBlv_60oM57dA Message-ID: To: Anthony Ferrara Cc: Nikita Nefedov , "internals@lists.php.net" , "rowan.collins@gmail.com" Content-Type: multipart/alternative; boundary=047d7bb040584a123e05210e26df Subject: Re: [PHP-DEV] Arrow function expressions in PHP From: bishop@php.net (Bishop Bettini) --047d7bb040584a123e05210e26df Content-Type: text/plain; charset=UTF-8 On Thu, Oct 1, 2015 at 12:28 PM, Anthony Ferrara wrote: > Nikita and all, > > > 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. > > The problem is that semicolons are non-obvious, especially in a > context where commas are used (and traditionally used). > > Example, tell the difference quickly between > > fn($a, $b; $c) => $a + $b + $c; > > and > > fn($a; $b, $c) => $a + $b + $c. > > At a glance, they are identical. You have to actually look at each > item to realize that there's a difference. At least with use() there's > a syntactical separator there to draw your eye to the contextually > relevant information. True. But a developer can mitigate with judicious white-space: fn($a, $b ; $c) => $a+$b+$c Or we can figure out some other such symbol. Worse casing no white space, brain storming: fn($a,$b:$c) => $a+$b+$c // not much better fn($a,$b!$c) => $a+$b+$c // better, but looks like not fn($a,$b&$c) => $a+$b+$c // lost in the noise, looks like bitwise fn($a,$b%$c) => $a+$b+$c // perl jibberish, looks modulo fn($a,$b--$c) => $a+$b+$c // multi-char, looks like decrement fn($a,$b::$c) => $a+$b+$c // maybe, kinda confusing // my favorite fn($a, $b @ $c) => $a + $b + $c; // vs. function ($a, $b) use ($c) { return $a + $b + $c; } // a space savings of 100% // unambiguous parsing // no backtracing // no new rules to learn about scope pulling // works if we later support '*' for scope pulling --047d7bb040584a123e05210e26df--