Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104714 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 49501 invoked from network); 14 Mar 2019 18:04:19 -0000 Received: from unknown (HELO mail-io1-f52.google.com) (209.85.166.52) by pb1.pair.com with SMTP; 14 Mar 2019 18:04:19 -0000 Received: by mail-io1-f52.google.com with SMTP id b6so5489636iog.0 for ; Thu, 14 Mar 2019 07:54:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=w+WBH24WRpTEHlmGrXFDtaeJsAcBB3rIS2fdcO2Kv9I=; b=E7hSTKUk4KE2yDiNCta/zglwnQzGx7r/bgwtYPIR3VK7wfvd1LLZXbrmiObpYurDBd gxXLVw/hI5Ea9gW4pWRde5A/aNXhydHuGo2cX0QragfQc+drIuAEGpFOZrCvwI1bliai hL8ZJjRStBnNDe9bzT+AVq0zqVrutNnq9cLnF98vdSIRQ6UDG5QS3vPB3VEUB6TDGMPq Nr1OcoH8md0g3m0lHOa1PLh5tztcl7xAFlmOmC/8K+UyJRPJqhFvQcHNHsa5pK3MSfbM PcETsFI+qgPUpnIe8NZhq9Vk5VmLNU0dBvbdgl9qLxs+3ZM7sir/gVVtxogRps1yJmP9 0hJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=w+WBH24WRpTEHlmGrXFDtaeJsAcBB3rIS2fdcO2Kv9I=; b=bLNNic0oYgWJQOWkQbfKQ8KLYIlg5RaM1oxLM3AVLjEPxf8i5iayGyP5KMnHRmDuQl 8RaIjTaTua8Rh11nGDajr340BpP/JIQh62RUrKLYpoTNFJ6z8mMgA2RPyPImm6kaVySX wImbYl8STH4qTZ6DvG9wBFYWf66P3aMTqC8YIpIFSmmz1ZvSkI9YfWSzClnLbxI80pW8 AtRpDJ119x+Y1BRoLJw9XpQ36yxCz5vS6c1c7jBq7GhFumxOJ8sv5ddgtVewb+l+9pMK eJqFHASuqD/A0gZPw5K1t3kh1p3jksr7P4k4Mp4tPaBWJaVoxfTa4JdHpQmoZ8iZhs2g MpBQ== X-Gm-Message-State: APjAAAX0HpPZyK1a+6mp8BVUjSGSBexnqvKz4ZZMyzONdqGtBrg8ZylJ yPEmE0ZqQRfJRDbpGhZk/2C8ug/jAaU9m+eS81AbH3UD X-Google-Smtp-Source: APXvYqzVmSLxxv9/kgEuxmqRH5pD0wJnREEGnhbiZFyVilI3pcnoQoZaiDScU4DiYE83aB2V2OK3MNb5iQ/I3E55X60= X-Received: by 2002:a6b:6003:: with SMTP id r3mr21292730iog.231.1552575283383; Thu, 14 Mar 2019 07:54:43 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 14 Mar 2019 14:54:32 +0000 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="00000000000040d5b705840f1a20" Subject: Re: [PHP-DEV] [RFC] Arrow functions / short closures From: rowan.collins@gmail.com (Rowan Collins) --00000000000040d5b705840f1a20 Content-Type: text/plain; charset="UTF-8" On Thu, 14 Mar 2019 at 14:12, Benjamin Morel wrote: > This makes me thinking, has this syntax been considered? > > ($x) => { $x * $y } > > Nested: > > ($x) => { ($y) => { $x * $y } } > Wouldn't this have all the same parser problems as the RFC discusses? The problem, as I understand it, is not avoiding ambiguity, it's avoiding lookahead. If you write: $foo = [ ($x) => { $x } ]; $bar = [ ($x) => $x ]; The parser has already consumed " [ ($x) =>" before it can decide if each ($x) is an array key or a closure signature. It's parseable, but only using one of the workarounds described in the RFC. If I'm understanding the RFC correctly, the only way to avoid that is to have closures *start* differently from other valid constructs, because then the parser doesn't need to recurse / backtrack / etc. Regards, -- Rowan Collins [IMSoP] --00000000000040d5b705840f1a20--