Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120659 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 58233 invoked from network); 22 Jun 2023 11:50:43 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 22 Jun 2023 11:50:43 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1F351180339 for ; Thu, 22 Jun 2023 04:50:42 -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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE, 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-vk1-f169.google.com (mail-vk1-f169.google.com [209.85.221.169]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 22 Jun 2023 04:50:41 -0700 (PDT) Received: by mail-vk1-f169.google.com with SMTP id 71dfb90a1353d-4714e9f07c0so1897990e0c.2 for ; Thu, 22 Jun 2023 04:50:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dqxtech-net.20221208.gappssmtp.com; s=20221208; t=1687434640; x=1690026640; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=TG8W5mm1/RGCU1/wV1aknwAb1cIXANzebjuxaFPAak8=; b=C8jlWLqj0CAyQxoSMidV0ZIXvZlXpO4Y0wNuwII6aN/Xg0OSJKw7c4FQ1jcCM/ARu/ uBc4nKJTJQk+klrf9tBa+utjkEqn0y3b+RMXQe90SXQU15OH7IbPC6U7pB6VCvoMvgkv oeJQT5OCXKAH80ppq1tzCCMJCy7PhaqaDnUhAsPQp36lAcTW+nY2kC/j9DGwIFFArbcq W6DKVZvWQwwccvAB57McbkLTXNGok2uaIzjcYESif1kvSVBV5YO4kwSt0VPG2Xulsjof cOHEiANZxlsiNuuk5lpCxdXXzBaHknh//pgfRUxWxlwttItrkbxGYKboMX50XsVrswdC 0QZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687434640; x=1690026640; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=TG8W5mm1/RGCU1/wV1aknwAb1cIXANzebjuxaFPAak8=; b=def3FxvquY/ceI0dZq7i9ItRWA5DqK5p5EupaQBFNLlW06S8wSu6o5AS9t3uPRJFKw UM8EesXhYDqxC8+/Ws+Ch/r6nIPNCPWp/A+A/yefq75qkZGzL8DiLPPwRF3Df8Zv50Hl v8F6kceMwkd9necu1/fd+Ouh4HV+hZHy4M8XQKFoL8kXtgBxuYBqN9X+b77bQI4Q4o1M R2DN7s9rMR061/w06o94Hp2rpHXwgnuYtypwTCUHA/aVBOUE0tryWgwPyg0W+oNsodPp NH8N2CctZvc1QuZyP7ZJTcJxXctJ+g4U6WU2nyjaDPQtZIT4C8ZYCMxenDzy6Ntn2VIw cVgQ== X-Gm-Message-State: AC+VfDzYo8Gu/tg7BFnp4UnrEYnPTEoznyjxFdM7wuGlnPg6YNwu08FU rh0ebcR/r5Mqw17zsv+Zb6YmR7cLLoMfDgIj34K9B8TDv52qTPmfl6B8qQ== X-Google-Smtp-Source: ACHHUZ6HE86mkbPtdLHzTta0EraDnGPwnw872WUJv4eH1lJCD+JkzMt8Rr/gGxyV0HoYzo2ggeqgpTZAaL4DVAgQBdc= X-Received: by 2002:a67:be16:0:b0:440:b709:b1ae with SMTP id x22-20020a67be16000000b00440b709b1aemr4847443vsq.16.1687434640529; Thu, 22 Jun 2023 04:50:40 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 22 Jun 2023 13:50:29 +0200 Message-ID: To: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] Expression code blocks From: andreas@dqxtech.net (Andreas Hennings) Hello Rowan, Ilja, (sorry I did not see these replies sooner, I do some forwarding but it failed) On Sat, 17 Jun 2023 at 16:59, Rowan Tommins wrote: > > On 17/06/2023 12:26, Ilija Tovilo wrote: > > I don't believe blocks for general expressions are that useful in PHP > > due to the lack of block scoping. Your suggestion to make the block a > > separate closure could avoid that (as well as the optimizer issue > > mentioned below) but comes with new issues, like making modification > > of captured values impossible without by-ref capturing. > > > I've been pondering various things in this space for a while, > particularly since the last auto-capture closures RFC. I haven't quite > coalesced on a coherent concept, but there are a few things that I think > inter-relate: > > * Opting into block-scoped variables, while retaining full access to the > outer scope, like JS "let" > * Code blocks as some kind of first-class thing, distinct from closures I think this would be my preferred option. We would have to discuss how variables are scoped and captured, but I could myself being happy with different options. Currently variables from outside in short closures are auto-captured by value, and nothing leaks outside: https://3v4l.org/mdJvM I would be happy if it works the same for expression code blocks.