Re: RFC idea: Block scoped variables with "let $x = expr"

From: Date: Sun, 15 Mar 2020 17:50:08 +0000
Subject: Re: RFC idea: Block scoped variables with "let $x = expr"
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-109033@lists.php.net to get a copy of this message
Hi Tyson, I think this is an interesting idea, but the way you describe it does seem to introduce a lot of caveats and additional restrictions. For instance, this feels very odd to me:
Correctness would be enforced as a best-effort at compile-time - the variables would continue to only be freed at the end of the function call.
Intuitively, I would expect this: {
    let $x = new Foo;
    $x->bar();
} somethingElse(); to be equivalent to this: let $x = new Foo; $x->bar(); unset($x); somethingElse(); Could you explain a bit more what the difficulties are in implementing it this way? Regards, -- Rowan Tommins (né Collins) [IMSoP]

« previous php.internals (#109033) next »