Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104711 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 31610 invoked from network); 14 Mar 2019 16:53:49 -0000 Received: from unknown (HELO mail-it1-f179.google.com) (209.85.166.179) by pb1.pair.com with SMTP; 14 Mar 2019 16:53:49 -0000 Received: by mail-it1-f179.google.com with SMTP id g17so4707413ita.2 for ; Thu, 14 Mar 2019 06:44:12 -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=FyyBQniR7f6xrk5/85QtogPiky0zk+qmUxLr4cl+xBs=; b=ak/bHMhixLkCZZjDOMMVSRUni3qY4IsSk4kHCXXUmVDXMz9OFQoPHEGspZfYDCHQqK NmqePuoLPHEyZQSXRvU9xumkm8t+Ro2y4vWIVSrrCulan5iB+RR/rhuJXn5OeXrTfJuw pDCwu+og5LKhUj5KNjfNEliDQazg+OjtGCTsUrxyT3ILJ79Oc7A9QiM6z1B2NDRU/hUP mHmcLfvh913alejwAL/AjuYHSliUQC10i/nMUTeeLMyuH4lYjq/dK12QCSH9yyLbWObi ScoES5swB8ZHnWdCPc1pgUbaAPPbuPiIcIz44Sz7ymRJAYmd3y5ib+lun7MlnMbILQuh pk8A== 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=FyyBQniR7f6xrk5/85QtogPiky0zk+qmUxLr4cl+xBs=; b=ojLMWvaXZHsy8Y0oqUcfu84BFFSVfP2w3/T85TDKHMyRB91wfqvXOHQCZuX0c92Djb gD6cTEsucnd0mNQ/T9NJPqhxPPbjq/4vY9SwmZAmVl/MpWKoaH8FjymkzHIAZUcNOu8s PbHmRCWJGs9mO1Ji54lv9Rc+vb84lE7N4kb+PuiM9fKOwOXxrHQTe9FNYI6Cy9CwoGcZ IYAcDYBgynQzMFj6IjCvmA8Zzp9yJ8ioX1vDyrsVzr+kTKXuOeeucAu8iFY6k8+ESx4c jDIKf1JuKlN9rejuZtXRO7167ljYpkKDI6dJJBM42P9Ji9tgHsI/4n4qZiXZnaSUVNGj IJrA== X-Gm-Message-State: APjAAAW6hn2+RD4VUcNig9JYdja4gmM6iPZ+0QtU1ewVl0bhWmBkBA8q R+Y4dZVsWkH9dGGnBgQCD2lzXZlNZKbNp8zclne0Jsll X-Google-Smtp-Source: APXvYqwdmcQOS/jGgrfx+BQJNLamWUkoz4RXdSd9h2KeLIQcplPH2XSWgb6r7IDu/JbHgk973abxW0lw9fdiIypOuCI= X-Received: by 2002:a02:91c8:: with SMTP id s8mr15317571jag.66.1552571052164; Thu, 14 Mar 2019 06:44:12 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 14 Mar 2019 13:44:00 +0000 Message-ID: To: PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [RFC] Arrow functions / short closures From: rowan.collins@gmail.com (Rowan Collins) On 13 March 2019 15:56:40 GMT+00:00, Nikita Popov wrote: >Motivated by the recent list comprehensions RFC, I think it's time we >took >another look at short closures: > >https://wiki.php.net/rfc/arrow_functions_v2 Hi Nikita, Thanks for reviving this. I think the RFC does a great job of justifying both the syntax and the behaviour, and focusing on the most used features without ruling out further additions in future. In particular, I think whether and how we support auto-capture in full function bodies has its own pros and cons to debate, separate from auto-capture as a convenience in short "lambda" expressions. I was initially quite drawn to a block-style syntax. As someone not particularly familiar with functional programming (which I suspect puts me in the majority of PHP users), I actually find it easier to spot this as "a closure returning a closure": { ($x) => { ($y) => $x * $y } } rather than having to work out the associativity of chained operators: fn($x) => fn($y) => $x * $y However, I imagine the only people who will heavily use such a construct will be those who *are* familiar with functional programming in other languages, and will find the simpler syntax more familiar and convenient. It would also be ugly to add full block bodies in a similar style like { ($x) => { ... } }, and while I'm not convinced we need that, we probably don't want to rule it out completely. As such, I support the RFC in its current form. Regards, -- Rowan Collins [IMSoP]