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 <rowan.coll...@gmail.com> 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.

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to