Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112013 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 47398 invoked from network); 6 Oct 2020 12:55:54 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 6 Oct 2020 12:55:54 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3663A1804B3 for ; Tue, 6 Oct 2020 05:09:15 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_05,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 6 Oct 2020 05:09:14 -0700 (PDT) Received: by mail-ej1-f42.google.com with SMTP id p15so17268036ejm.7 for ; Tue, 06 Oct 2020 05:09:14 -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=mknGuDa5PYBx6e1dU/+hP0GMzJGGBa9hVH4bgWgkUmk=; b=IGSndImo1H+SUNGf2JyvefFOls1kwU+cvAWHE0lW4hF3D8NFiykAMtyEK1BJ5ml8mz we5iMMXlm+po+r1C1obrDCLHYqYp0QCwa/mHCCjLuFa6IvE3uhuTiJkUBVd5RLVKyFbL dC0K61YB/dP1eB1aIiA6vP9GLQj1WQHMv57znqXbgXmuWBnoMBGvvdF69C1k8iJhUTU8 h/APGpIDGd2cVakUMkthHV1jrRWSN03FLZ7ARVExz9oxxKiCbqLQ+TEgohHQbh3FZ6lk td+JPUZHpW10cJjRFB5T2jqDkZQ/1z/v79vwBiC+w3A22SH19Y+GTohVVQNlEPyyCTfo FEQg== 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=mknGuDa5PYBx6e1dU/+hP0GMzJGGBa9hVH4bgWgkUmk=; b=P6AA4rfgN0Nmz7G4Vw+20K6qCGebpzG2oDrLoiJOQdGAeSHDjtt8bukOcFmrXpD+mn sHAiAR99Q+upAAINlynN2S+dioNT1J7m9Hnkdws+eDko1C9Qt4L4ND3ERUAZSoX0QiaC MiQqpx0LP5ZuVH54H/Wf/hCtx4/U4MYaQt8unnjZ+C/LxGGa8uSd3QWjbIKsJKI8hB5U /+D72UPyR+moVDp++9TEri1v7EqXesaWBw6O0AnmGlD0teRYrV0d7iKJvHbbtEGKs0Fz R9jgxbwT8KHNWa9R1gg+c8LyOhUzUNB0RR7ygQawlZ9hldxWvgHNWvhE89j3Ty+SFzOV hRcg== X-Gm-Message-State: AOAM531FCQgQGCHFEmO7JTuZYhjE7E+gozM5AL75roG7gBMh5Jx3E0xd 3jlx3E/Ejuj2YRVC2vBmnZFgYEz5xmCvf+Q6rnvLZoOJl94= X-Google-Smtp-Source: ABdhPJx0mneop4nSAtuUewvJsgmz5A/Lji4+u/tfzhszczOxJSfIbQLUq1SL392iZrBLVx/Hu3UOaQ2r2chQx4AI4io= X-Received: by 2002:a17:906:edb0:: with SMTP id sa16mr4791930ejb.327.1601986153503; Tue, 06 Oct 2020 05:09:13 -0700 (PDT) MIME-Version: 1.0 References: <446c9894-191f-e53b-4534-31c4e7b91d7b@gmail.com> <881e2335-5f81-0d79-6a17-06bc20f14223@gmx.net> <873361ff-02c8-b9df-9b7a-c9e89e25a880@gmx.net> <7F014A40-2D47-4DA6-8A38-59518218F9CA@stitcher.io> <9A58B811-37C4-46C8-A7A9-B558752362F3@stitcher.io> In-Reply-To: <9A58B811-37C4-46C8-A7A9-B558752362F3@stitcher.io> Date: Tue, 6 Oct 2020 13:09:01 +0100 Message-ID: To: Brent Roose , PHP internals Content-Type: multipart/alternative; boundary="0000000000009d5f9805b0ff7770" Subject: Re: [PHP-DEV] RFC: Support for multi-line arrow functions From: george.banyard@gmail.com ("G. P. B.") --0000000000009d5f9805b0ff7770 Content-Type: text/plain; charset="UTF-8" On Tue, 6 Oct 2020 at 12:20, Brent Roose wrote: > The point of short closures, regardless of single line or multi line, is > addressed (and agreed upon by the RFC votes) in the first pararaph of the > RFC [1]. I'm not sure if I can add anything useful rather than saying "it's > nice to be able to write more consise code. It feels a little more smooth". > The thing is, the RFC voters have agreed on single-*expression*, there is a high likelihood that if multi-line (i.e. multiple statements/expression) support was included in this RFC it would have failed. Why do I think this? Look at the previous vote: https://wiki.php.net/rfc/short_closures So your conclusion about what the voters agreed is completely nonsensical here. > There's actually one more argument to be made: they would make the use of > closures more consistent for those of who _prefer_ short closures. Now > you're forced to mix up both the short and long syntax. As an example, I > use Laravel's collections [2] which provide a functional API to interact > with lists of data. You often chain these calls, and are able to use short > closures like 80% of the time, but sometimes you're forced to use the > longer syntax. > > So that's my two arguments for multi-line closures > > - Making code less verbose, which is the _same_ goal of single-line short > closures, which was accepted by the vast majority of PHP > - Consistency with already existing single-line short closures > Ignoring the first point, refer back to the previous paragraph. What consistency is there if there is no implicit return in the block form? Sure it is annoying that for a 2-liner, where you probably won't "forget" about the fact that you are importing the outer scope it is annoying that you need to go the longer route. But that's not a sufficient argument IMHO. > My point is that PHP is evolving towards a modern language, and with that > come syntax changes that not everyone likes or wants to use. @ for > attributes isn't chosen because it simply isn't possible to support that > syntax, not because of what the community _and_ internals want or don't > want. I don't think of this as a counter argument to my original point: PHP > has seen a significant increase in syntax sugar additions over the past few > years. If no one wanted those, they woulnd't have been voted in. Would you > like to address that argument? Why are promoted properties, single-line > short closures, named argument, etc added besides that there's a "want" for > them? > The core difference here is that it doesn't change a *fundamental* aspect of the language (or in the case of single-expression closure it changes 3 aspects making them very special), you might not like this aspect but it is still present. Obviously nothing is necessary, we could write assembler style with only goto statements. That's exactly what I'm saying! It's ok to add syntax to make a developer's > life easier. There are cases where that's a good enough argument. > And this is not one of them, at least for me, and I don't think I'm alone here. > Why was auto capture added to single line short closures last year? We've > had this discussion before, and the majority of internals voted "yes" back > then. So instead of only re-iterating the same discussion, why not provide > Nuno with useful feedback as well? > And once *again* short-closure don't *just* have the auto-import of the outer scope going for it. The other main features of the short closure are not applicable to a block syntax. - the fact that there is an implicit return - it is a single expression, *no* braces therefore it doesn't look like it creates a new scope. You ignoring these facets which are key benefits which only apply to the short closure case, to imply the extension to multi-line is a "no-brainer" is not making a case for it. My opinion is already that the way PHP does closures is the Sane Way To Do It TM, you have a dependency on a variable therefore you need to specify it, is IMHO a good thing. Do other languages function just fine with the opposite behaviour, sure. At the same time Java has implicit nullable type arguments and people deal with it. Best regards George P. Banyard --0000000000009d5f9805b0ff7770--