Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104740 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 65704 invoked from network); 15 Mar 2019 14:00:32 -0000 Received: from unknown (HELO mail-it1-f181.google.com) (209.85.166.181) by pb1.pair.com with SMTP; 15 Mar 2019 14:00:32 -0000 Received: by mail-it1-f181.google.com with SMTP id l15so10079810iti.4 for ; Fri, 15 Mar 2019 03:51:09 -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=jVB7WD2z1qIfoGWdiP/FbNTPMlvy+zECdp5vayWJN3U=; b=qT4Eoazt3JNUlnW6NYiVhvypTWIU5hHqqFojYQMBzZJ7ifMdAb4vE3boTbn623A0IE R6GUoAyMhj7I4i+JAc8kGu7AQo74ImKCqp6+VnPw3epWh+hHtNic+bVNOdCaU7ctcRgg dN4rG0Q6BpzLamKhcAir2ZTAjNHAmVJ+4nUnsYsHMUJUEmr9jiCZty9r7oKIJ/BraDDW z1Mon+fBFqBtDKF7M4D4wdFT85TJvE+7NbbSQIzWSU8v972HBYk1+MuqoLddhfWEy/NM dhTaG8bwUfA4BBsfOrInQZ2wXuJ9uZhu6qZisEWT94p8l4lbS25lzDxa1fqwcmJlDgXM vkSQ== 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=jVB7WD2z1qIfoGWdiP/FbNTPMlvy+zECdp5vayWJN3U=; b=F5TU1s9iiiUN6Hl4SxKKD1K7NEDfBXd2LamyuLGkjiQB7BxgW9FkEQolbkoCA5EEtn pIMthsRckBG4GR4W0lof3q8RLpZ2ycHH8BXUf3jFUXJEJbylpeBP0YzyHQTuNODkc7JG +xc4+V8QHgE7L8ZwY8FgdhlRyWzlB5NohjebrI/KKDVWN9o+uJURM5zwEnRxs/ggzNLO 3lOktI3GN1aEPBmDZva4IvzGPHOBhy1rRhS0W8TO+M2eo7MfsQSGIRagcJyZ+ras5dUP SwjjLHkHevcxxlDoUeAOKH9cekSSA95s2uw2EYTU0kZfatiPQd6hbmXr1LbiIHTuVWi0 UHGw== X-Gm-Message-State: APjAAAU6fhjHmkLGnF/n090aFcCQqkBHBWdJHzuh2EddVanme+L0hs7Y 6vYn3I9d1sYJy06UvrKEWbgBnTmbk2gaWMyG1tVkvw== X-Google-Smtp-Source: APXvYqzxkQIrinkuO9wfWbxBUF51ywAfBMXN+80oYyxiyYjcimCUjg21336k9simaG+IVQNp4cqkKPkcO0PrXqK3BTs= X-Received: by 2002:a24:164d:: with SMTP id a74mr1489316ita.84.1552647069023; Fri, 15 Mar 2019 03:51:09 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 15 Mar 2019 10:50:57 +0000 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="00000000000002c48e05841fd1fd" Subject: Re: [PHP-DEV] [RFC] Arrow functions / short closures From: rowan.collins@gmail.com (Rowan Collins) --00000000000002c48e05841fd1fd Content-Type: text/plain; charset="UTF-8" On Fri, 15 Mar 2019 at 10:10, Nikita Popov wrote: > It might be worth giving some consideration to the possibility of > introducing this syntax already in this RFC. The main problem with punting > this off for later is that it may be necessary to refactor closures between > the short and the long form regularly: You need an extra statement in the > closure? You have to switch closure types, and also not forget to write our > the use() list this time. > I know I'm not necessarily in the majority, here, but to me, that's a feature not a bug: short closures should not be a replacement for every anonymous function, they should be for those cases where you have a really simple expression. At some point, you should be saying "this is now too long for a short closure, it needs a clearer definition", and "more than one expression or statement" is as good a heuristic for that as you're likely to get. I also have strong reservations about generalising automatic binding to full function bodies, because it fundamentally changes the way variable scope works in the language: right now, $foo is always local to a function, unless *explicitly* listed as a parameter, imported with "global", or captured with "use". That's a lot simpler than the scoping rules of a lot of other languages, and it's a guarantee we shouldn't break lightly. I'm willing to be convinced - or simply "out-voted" - on these points, but I think they deserve their own discussion. I was shot down on chat the other day for a naive remark that capturing a large number of variables in a closure would be "doing it wrong"; I'd love to see examples of where this is useful / necessary, and a new RFC would be the perfect place for someone to put those. That could mean another RFC proposed immediately after this one passes, and the feature arriving in the same PHP version, but I don't think we need to merge the two discussions - as long as we keep the possibility in mind when choosing a base syntax. Regards, -- Rowan Collins [IMSoP] --00000000000002c48e05841fd1fd--