Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118861 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 11326 invoked from network); 20 Oct 2022 17:03:06 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 20 Oct 2022 17:03:06 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0D27F180054 for ; Thu, 20 Oct 2022 10:03:06 -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,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 20 Oct 2022 10:03:05 -0700 (PDT) Received: by mail-wr1-f48.google.com with SMTP id j7so35741684wrr.3 for ; Thu, 20 Oct 2022 10:03:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=SAc4lLB9I24lGaabz7gfnGf7WsrchUq0ixxHad7oOxc=; b=hsasKMuZYaIxOC4rs6u7ohCkB6TqAIKfNJe66LNbmcqw/j2Mma6NHa3+6wInJmq45k t6qTaCOcmcLf0hSHtjE+LSvsM0t4yi66EaFS4b58tBNfXorNUlrGcqrq6F6eU/AynBQI S141nKAij+I11VYT/RGNtht8sPcj0YAunCmO5i1HLbSstqxmXH5Vy+8XzuKyRcelFGIH RdCWka0nRo7vdLFk+3jq4W+2YCPwtdfGs4ekDnM2VG86EB4V1+nHQd8pi1SOdMDVl8m4 ROUvqR8cvXdscFjPXGJjyfR7Z1Yc1r0HVWRACZ91kzAWh0jdJ4EnELW7uZW8dc5fyVLZ KENA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SAc4lLB9I24lGaabz7gfnGf7WsrchUq0ixxHad7oOxc=; b=XPJ/WR8Ungc0uXhFGyXf6vF0otl7HYp3M2v5/5WGC5TFe5TU0ZHN20eirbFjULdKa3 WuCLj1XAYNKtFwU4xWpGWnk9bD1Xe6cXyPSiHXCtql6bRoHh0OcGXVB9snZTg3bhl1tc +q7NRUiZ3dHDM3w4g73B94Ah3/ZjmfQTIKYwxM0jHvOjgNksqKDW/t1qGVEiITaP+2Sm Y97S/RNklCh2Vg5d5kenBjIDUgmhvzyW1pt+L3AEq+3cjlBmRVV68c8NqmyVLXcQKst6 0IW/wxVrtodE0yY9T7VhBT/mF0bsDLkIxu/vKSUrdDJzJFHVaO2iBVZ+b5odkzD4DKIP EoGQ== X-Gm-Message-State: ACrzQf0zKBVlE+37qoFkshwqa/D036akRnfidU//+tYLF+VlrIOHKla5 dQYxH0WJt5VEqnAyYttAvkc4h4GS3do= X-Google-Smtp-Source: AMsMyM7sVxyWR65NH5faXYKfvA4I2QrWG6G+WPyVReHpneGbvbSP9lFyENXJLb1+FE21vYKA6TFGTw== X-Received: by 2002:adf:f00b:0:b0:22e:3439:cff2 with SMTP id j11-20020adff00b000000b0022e3439cff2mr9799142wro.719.1666285384185; Thu, 20 Oct 2022 10:03:04 -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 bg6-20020a05600c3c8600b003c6f3e5ba42sm317449wmb.46.2022.10.20.10.03.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 20 Oct 2022 10:03:03 -0700 (PDT) Message-ID: Date: Thu, 20 Oct 2022 18:03:02 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.3.3 Content-Language: en-GB To: David Rodrigues Cc: internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Compact can't resolve outer scoped variables using short closures From: rowan.collins@gmail.com (Rowan Tommins) On 20/10/2022 17:48, David Rodrigues wrote: > Regarding this, in case you're literally saying that internally "fn()" > turns into a common "function", and getting back to the main topic, > would it be possible to do the same with compact()? > > fn() => compact('dummy') > turns into: > fn() => [ 'dummy' => $dummy ] > which turns into: > function() use($dummy) { return [ 'dummy' => $dummy ]; } Yes, that is what I meant by "it would be possible for the compiler to special-case this scenario"; I explained why I think that would be a bad idea, and suggested an alternative. Regards, -- Rowan Tommins [IMSoP]