Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113772 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 17748 invoked from network); 25 Mar 2021 14:42:46 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Mar 2021 14:42:46 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 61953180506 for ; Thu, 25 Mar 2021 07:38:48 -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, 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-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (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 07:38:46 -0700 (PDT) Received: by mail-lj1-f177.google.com with SMTP id y1so3387932ljm.10 for ; Thu, 25 Mar 2021 07:38:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=8pgIpxfPE3LeWLDVtUvUYNpzsPXccqlbBH1lf/KmBkE=; b=JtGS9XL0gKiTNjalSq6B6f1KGo5G7VcM7e+MLjuiZGUvDQUwiXyhAbYaDXoRBkWK9w AOW28O/W06l6fzRVx+XJWqRnMzZLUgdHgIGTSpZrXnGXODojZBcPgDoDSn2UyZDQ6VE7 WWxQhg4QLZtXXFLYwfqBV3x/Y1W+JklElMbqTO1cXJ4/GHRHwEA/lq0flkJY0MHrdJjY eEmKn2LewEffMUkN/QHlRwqcV7LGfP1DEFjj85TVo3155/CaMYxRk3Vb88fWgMgRVWoF waauvzhR8pNFPwBsGM2eHyjoT/cjy7qkkyAv+0O3iORUUhGeb7w/SCyQZkTZ95fI/dR4 L+kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=8pgIpxfPE3LeWLDVtUvUYNpzsPXccqlbBH1lf/KmBkE=; b=Jpkao18WvGQv80t10sGd/jxzsAQtMMqUa+e2iasegVvTHbBdf2R9KUBFlg7/vA5HVJ 12ofRkS7/jWAQhbGGCMLPfTjmRwZbWMQUOGac8lDcYfCegAIXIMMLO2Au1IiT2NfmTdL dsySNn2TQsv+ipyK6q/AfAIxb6Pxa9elkbKiDEw7lc/ULPKQsw6Z2VJlHATadFvYsrh3 voIx6XOIkhUrOgeduWtV3QV+tAZozB36QlLP12qazobW+15TgwDdX2cNogmWrN3yAqRd PbNjbxFagJWCep8pV0k85/EL9ogfHx+9pEg+VPI2v+Tv+WMsSXN+ywaHfaJpou6p+r09 yb8Q== X-Gm-Message-State: AOAM5302g7Jn9m3vXdTicwopVLxtIHinOm2i4XcrfCa878mvMSSmP9ZY QyJuT6ehhZZott/5Q63477ZwmLDXi47BJO8Vxnq1+l/l X-Google-Smtp-Source: ABdhPJwMf7Rmkp8MPiJfC6bh216IEkEYBq9y485KajQ6Nx9JoQSoUh7lQoGPFg8YEoJqsz+OwCf3bt8BWRslMUVGm2Q= X-Received: by 2002:a2e:86d0:: with SMTP id n16mr6117725ljj.288.1616683121678; Thu, 25 Mar 2021 07:38:41 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ab3:5f8f:0:0:0:0:0 with HTTP; Thu, 25 Mar 2021 07:38:40 -0700 (PDT) In-Reply-To: <5D33D73A-6B75-456B-9774-91F71FF450BA@cschneid.com> 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> Date: Thu, 25 Mar 2021 15:38:40 +0100 Message-ID: To: Christian Schneider Cc: php internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [RFC] Auto-capture multi-line closures andshortfunctions take 2 From: olleharstedt@gmail.com (=?UTF-8?Q?Olle_H=C3=A4rstedt?=) 2021-03-25 15:23 GMT+01:00, Christian Schneider : > Am 25.03.2021 um 14:29 schrieb Mark Randall : >> On 25/03/2021 09:28, Rowan Tommins wrote: >>> That's not quite what I meant. I meant that you can't say "capture by >>> default, but this variable is definitely local". >> >> I think if there's one argument against, this would be it, but IMHO it is >> a weakness in PHP as a whole. > > I'm not sure if I misunderstand what you're saying but to me it is one of > the greatest things about PHP that everything is local by default (minus a > narrow set of well-known and easily enough recognizable things). > >> The solution would be adding JS-like let / const statements. Which would >> be a benefit to other things too. > > > I disagree that this is the solution. I think JS had to add var and later > let because of the unfortunate decision to have C-like scoping rules. > Making scoping in PHP more complex to be able to repeat this mistake in some > form seems ill-advised to me. > > - Chris You could make the change that *all* variables are now block-scoped, not function-scoped. That would make auto-capture less dangerous, but I don't know how much code it would break.