Am 15.03.2020 um 17:47 schrieb tyson andre <tysonandre...@hotmail.com>: > { > let $myObject = new MyClass(), $flag = true; > $myObject->process($flag); > } > // Accessing or setting $myObject or $flag outside a different let is an > E_COMPILE_ERROR > // because it was declared anywhere else in the function body > // as a let statement > $myObject->doSomething();
What you are suggesting is that a let statement would switch PHP to an altogether different mode where function-scoped and explicit global variables were suddenly disallowed and an error within that function (or only after the let?). What about variables not declared with let, would they still function normally? That sounds like a bad idea to me as I'd have to look at the whole function to see if there is a let somewhere to determine the function's/variable's mode. I think that 'let' would only be feasible in a similar fashion to JavaScript: The lexically scoped variable disappears as if the whole block was not there. How complicated something like that would be to implement I cannot judge and I haven't spent a lot of time thinking about other problems of this proposal. - Chris -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php