Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113792 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 56003 invoked from network); 25 Mar 2021 17:29:15 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Mar 2021 17:29:15 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 895031804D8 for ; Thu, 25 Mar 2021 10:25:18 -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-vs1-f52.google.com (mail-vs1-f52.google.com [209.85.217.52]) (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:25:18 -0700 (PDT) Received: by mail-vs1-f52.google.com with SMTP id 124so1289768vsg.12 for ; Thu, 25 Mar 2021 10:25:18 -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=QjTAjRkuz1CggnIOYQTGWrx6weoHMiAhVGDK/RM3CGk=; b=KAr2HpQmegHgDQh/KkcWn1Vt41z88vbRPwNtLY0CVYXJbx1e6cyL5HGmT5Ef1KFv4G 7b+Vb5ckPBOh5jFynwxKwpDcQTzjydHsObDiHUAfnUOnQqORTdrbzN2twjqDOxCZZAse kf6W5LUqUXUjfCBtBNEvpPJyoq2vJWhXCq94nS8/HK647fHCHFAcQLrq36pvA7qw7ZER cCrLQ4Sps5SdcJFs0qf1nAbWoe6EgCSpTz3h1zWY3XrkQsELb13nKp2x1SLshXWhlP5M C3roDZoNo2ZRS+ks/q2zuSXLe81ROV2DLG6QmOcfVyQlxzi9uMsj6TttZig7QA4OyVek vLqw== 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=QjTAjRkuz1CggnIOYQTGWrx6weoHMiAhVGDK/RM3CGk=; b=ijstVVBhJZCNxy/HU0UvZ2CH0fZVxpL9wR0fO0tXt6allJxJmwgXWY31GvpDiyZiDY qjkpO1QdTr6igLRmUURBB9xpIeYfbENnXDDp5QBBhD7Yo5MjKDEPQT3+8tDpN5RrS2M3 xCEJa1BTK6JswzDyH94lnFcMfMeNgCIlCeX1vwWrvPYpAzQZv9Da3YBUKE0H7rJu5pX2 vH3b1fyP76BQ1DBKLpYoIIBFshDwKe+4w1ptN0/a7gIrCoY9l2xYtJ1R357fKNd3NIkg lzJESEDNUAXJriO0LFYoYt/5zCZwwVA4xA5mN1NXrDTClru4UaygZUM47qRPUoUB+N9/ k7pQ== X-Gm-Message-State: AOAM531PqLNilkvWMhAzuh/ihEIVRa2m5d+5UGJutSMheJPEKt8nL5UY qIx+xoPf2DgVtrLSZQO5BlfHGf/sHGHKbCxgcUE= X-Google-Smtp-Source: ABdhPJzsmNQxZUoIAPiO7kKDT7yr7/KB4ZNXxX6hFFStsLLvQHY54zSmhMK7QLniHI7JXt8B62qf7fZiZ6KiVL1yQUY= X-Received: by 2002:a05:6102:22c8:: with SMTP id a8mr6248240vsh.13.1616693115983; Thu, 25 Mar 2021 10:25:15 -0700 (PDT) MIME-Version: 1.0 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> In-Reply-To: Date: Thu, 25 Mar 2021 13:25:04 -0400 Message-ID: To: =?UTF-8?Q?Olle_H=C3=A4rstedt?= Cc: Christian Schneider , php internals Content-Type: multipart/alternative; boundary="000000000000e39b6d05be5fb235" Subject: Re: [PHP-DEV] [RFC] Auto-capture multi-line closures andshortfunctions take 2 From: chasepeeler@gmail.com (Chase Peeler) --000000000000e39b6d05be5fb235 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Mar 25, 2021 at 10:38 AM Olle H=C3=A4rstedt wrote: > 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 (minu= s > a > > narrow set of well-known and easily enough recognizable things). > > > >> The solution would be adding JS-like let / const statements. Which wou= ld > >> be a benefit to other things too. > > > > > > I disagree that this is the solution. I think JS had to add var and lat= er > > 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. > > The BC implications would be huge, not to mention that it wouldn't be a good idea anyway (at least in my opinion). The following would no longer work: if($check){ $match =3D true; } else { $match =3D false; } //stuff if($match){...} Yes, that could be done in a way that works with block scoping, but the fact that PHP has never been blocked scoped means there would be a LOT of code that would break if it was. > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > > --=20 Chase Peeler chasepeeler@gmail.com --000000000000e39b6d05be5fb235--