Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113787 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 48391 invoked from network); 25 Mar 2021 17:05:51 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Mar 2021 17:05:51 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E60901805A8 for ; Thu, 25 Mar 2021 10:01:54 -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.6 required=5.0 tests=BAYES_00,BODY_8BITS, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, NICE_REPLY_A,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-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (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 ; Thu, 25 Mar 2021 10:01:54 -0700 (PDT) Received: by mail-ed1-f41.google.com with SMTP id dm8so3256864edb.2 for ; Thu, 25 Mar 2021 10:01:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=7NBurisfxUvxv6Lj1CgojPTdDEMotb4onq1s9wmA1eg=; b=B0MLFcqKTX6LmtMmHDOdggEZ8COGpWJ52FVfBZk2hmiXhS/NG+cd7mhrj6ZIaqj4my +8O3+c7zuPRbrtj3kRzh+DsJp1WKeX5f5h/gi6BCOQjsI59x+SKop7LsXd0LMGFUx+dF MZuS+LWU3sFbwk3y9GKKU59I21Q0sN1gwYugB7tX4KwuLVZqj86jn0ffdIcSg4Jv9Snb ABDLi30Il+njG2X7le5d7FohtJXpUbgIYhXTalu23SPlchhlgDIkBXmrprh/w4eSXjq+ pMO3niA+uLfe5hhekroMG5sGp0Jk2qtD0Pl9PT5IR+3xd5aGdXZwo8FewDfLEZUMSyQK TRMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=7NBurisfxUvxv6Lj1CgojPTdDEMotb4onq1s9wmA1eg=; b=mRReXkuIh1+iWEN33lCaNEF8Zjhd7RXRRji1GNHhx8OSvvB2Dmj7jfeeo92JD0D4xs zMGYwwgwFYi4qAA2gOqt0ER0xJcNqQhxnYrSrnqpPxqlJOHms04MvK0UQtThnLq7/z1u Czm/VLH+P35Fc6ncnBdcI9YAJZ8PHsGptHymW7txS0VkXLM9caSUBYFnz5jbFp5uPz4v F9T7ws/JTB1VacT3hQYVAw3k3nxColae2njF1n3MvCciL+UHo3UBTHcnO10e4I/wJS4r fuITVcZ8X+h0xivRKB2a9QZeYCL1xlOIt8VutWldScMAtbGIKdfBQgue/6aQTrZMaEuQ rnEA== X-Gm-Message-State: AOAM533yeA+1FBtoUxGtJBTOv/j2kEgo1SYGVv/eRztIPljzwWKaCgF/ b6p16csaIMgASUSWH45AqUcxWCV+jJo= X-Google-Smtp-Source: ABdhPJzLYInsgMy3CJHHADfMYjcS5g6Q0LOLRok7GRUN841FW5z8Y+9RpWD94FTZ0gAp76JF8fGtTw== X-Received: by 2002:aa7:c1d0:: with SMTP id d16mr10050779edp.153.1616691713221; Thu, 25 Mar 2021 10:01:53 -0700 (PDT) Received: from [192.168.0.22] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.googlemail.com with ESMTPSA id u13sm2769484ejn.59.2021.03.25.10.01.52 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 25 Mar 2021 10:01:52 -0700 (PDT) To: internals@lists.php.net References: <88c9eb5f-f80c-4869-b7f8-1b58b9e2eaa3@www.fastmail.com> <4DC3B66E-A91A-4AA9-8872-8EE9DE92C2D4@cschneid.com> <8c72c162-83c0-7c7f-2fa7-4fbe3fb30a4a@gmail.com> <605bae82.1c69fb81.f49f7.d11eSMTPIN_ADDED_MISSING@mx.google.com> <919e30e7-3e5e-d955-7bb4-1e1b5825cdd1@gmail.com> <635DD146-FC6F-4991-8D2C-5A6B492722D5@newclarity.net> <734f12de-da98-6b76-c2fe-8682f4d177aa@gmail.com> <5D33D73A-6B75-456B-9774-91F71FF450BA@cschneid.com> Message-ID: Date: Thu, 25 Mar 2021 17:01:52 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [PHP-DEV] [RFC] Auto-capture multi-line closures andshortfunctions take 2 From: rowan.collins@gmail.com (Rowan Tommins) On 25/03/2021 16:24, Nuno Maduro wrote: > Concerning the comments about what's exactly "auto-captured" by the scope > of a multi-line short closure, we will be just reusing the "auto-capture" > feature that already exists in one-line short closures. Therefore, this RFC > doesn't have plans on changing the way "auto-capture" already works in PHP. This may be technically true, but it's not particularly helpful. I'm not sure if the details are actually documented anywhere, and there's an awful lot of PHP code that either can't be used in a single-expression closure, or is extremely unlikely to be used. For instance, which of the following will capture $a? $assignedBeforeUse = fn() {     $a = 42;     echo $a; } $unreachableUse = fn() {     if(false) { echo $a; }     $a = 42; } $assignedBeforeUnreachableUse = fn() {     $a = 42;     if(false) { echo $a; } } $unsetRatherThanWritten = fn() {     unset($a);     echo $a; } $outerClosure = fn() {     $nestedClosure = fn() {         echo $a;     } } Regards, -- Rowan Tommins [IMSoP]