Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113745 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 16101 invoked from network); 24 Mar 2021 17:43:23 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 24 Mar 2021 17:43:23 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 964911804DC for ; Wed, 24 Mar 2021 10:39:12 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-vk1-f179.google.com (mail-vk1-f179.google.com [209.85.221.179]) (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 ; Wed, 24 Mar 2021 10:39:12 -0700 (PDT) Received: by mail-vk1-f179.google.com with SMTP id f11so5622351vkl.9 for ; Wed, 24 Mar 2021 10:39: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 :cc; bh=BJLKeC4PBd7dPam1+lKvmM8yDQ4QAYjJzE1Dg0dT1P4=; b=L9ZQ2NlwgNwGKGqFLWJMILmUbUFvcLpt8qy8Zam5N0BFFWrels4yd+5wEHAtUyxZDz HOV4VpvXawTaKdGyWOwvT3XgvQCQCGmGDg116eyCZbP0ihbCqBf2pwnPevby/0jd63In vT+gjGYXAGHjnHFGZFBNRzJUH+ObZzkRHv2BSCokptqJZRJ56LZNZNmXLJnawgcd0JJ/ PlPnTatWD3NNOJM/4ab8tNu0C+paPyMb/k0mvPzIDzRtnmba1aDFe/yJP8qihSnZ3c05 7SIwAVX5+7vT2anj8CaBWL6dkEV4EAYuprM/fYUr6A4Wbl/DCGPn2qBPvDIr/Txfi5Cp 758w== 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:cc; bh=BJLKeC4PBd7dPam1+lKvmM8yDQ4QAYjJzE1Dg0dT1P4=; b=IOk/L9cThixknYYsTZndikEHSKr3CrnPaOQ3X1JypMkuo1LIvXsepaVLrbGN97ROSe BdqNBx/1Y9WZAeT7Anut4DL47gRuruJNYNfLuZc/rCiL0DqpRF6+um7eAYR0lFDx1IO1 IZwnwVuZQ7w7oAJWfsqSNVaC875UxWczxgZIryHSEy/byRTzTHA5AzKxQ7S4VoPIh5zA nd86mkU7uDWeDVYQgKB3lExC8aQF750/zyugVB6jlWfR8/5nnrNWRkVcI6aUk3DaAZRt +aJcV+lL9CHA1WG8gD/GGLOHJsr5iwEQy1I4jKW9nmGGTaZTaSO1W+9H8xwPXHSwLzUx FMaw== X-Gm-Message-State: AOAM532GB8WTE0v+sK0yCEV5MJzdNNostjN+6kKDyDvydp4JSkE2cAKA 8ihlRHKXGFeG41SHax6nUrRRO91g5A/Jgp1REw4TDTrwneU= X-Google-Smtp-Source: ABdhPJz4gItxHzwd3T6Tk+qKXFp5UWhq+QWZnHqPxRDa1JUOewbvH87wgiZ9K1n6JKy0f0i2RIdUk4+eLOu/YVrA/+o= X-Received: by 2002:a1f:a8ce:: with SMTP id r197mr2748273vke.16.1616607550403; Wed, 24 Mar 2021 10:39:10 -0700 (PDT) MIME-Version: 1.0 References: <88c9eb5f-f80c-4869-b7f8-1b58b9e2eaa3@www.fastmail.com> <4DC3B66E-A91A-4AA9-8872-8EE9DE92C2D4@cschneid.com> In-Reply-To: <4DC3B66E-A91A-4AA9-8872-8EE9DE92C2D4@cschneid.com> Date: Wed, 24 Mar 2021 13:38:59 -0400 Message-ID: To: Christian Schneider Cc: php internals Content-Type: multipart/alternative; boundary="000000000000c87b8d05be4bc6ad" Subject: Re: [PHP-DEV] [RFC] Auto-capture multi-line closures and short functions take 2 From: chasepeeler@gmail.com (Chase Peeler) --000000000000c87b8d05be4bc6ad Content-Type: text/plain; charset="UTF-8" On Wed, Mar 24, 2021 at 1:34 PM Christian Schneider wrote: > Am 24.03.2021 um 18:15 schrieb Chase Peeler : > > I guess my one question would be why we didn't support auto-capture when > we > > first implemented anonymous functions, and if there was a reason, why > does > > that no longer apply? > > My guess would be that it was seen as one of PHP's big strength that > variables don't just leak into other contexts but that it has to be done > explicitly. > > Now with arrow functions both the benefit of auto-capturing is bigger > compared to the actual function 'body', it normally only spans a line or > two and (for me personally) the absence of {} also kind of make the leakage > fit my mental model more easily. > > For these reasons I think I lean towards -1 for both > https://wiki.php.net/rfc/short-functions < > https://wiki.php.net/rfc/short-functions> and > https://wiki.php.net/rfc/auto-capture-closure < > https://wiki.php.net/rfc/auto-capture-closure> as they add more syntax > without (IMHO) a huge benefit. > > You might be able to convince me otherwise though ;-) > I don't really have anything against auto-capture, was just kind of curious. I guess it is somewhat similar to how x = function(){...} and x = () => {} work in javascript with respect to "this". I do think it makes sense to only do auto-capture on the short syntax, so that you still have the ability to fallback to the long syntax if you don't want auto-capture, since there are definitely use-cases where it wouldn't be make sense. , > - Chris > > -- Chase Peeler chasepeeler@gmail.com --000000000000c87b8d05be4bc6ad--