Re: Lexical scoping
Hi!
> Perhaps a future version of PHP (PHP 6? 5.7?) could have lexical scoping with a
> "let" keyword? At the very least, it would make foreach() with a reference less
> of a problem:
>
> foreach ($array as let &$a) {
> $a = 3;
> }
> // $a is not in this scope - no need to worry about accidentally changing
> last array item
Typing unset($a) takes about 3 secs. Since you need to make additions
anyway, and you can already easily do it in the language - I don't see
any need for introducing new syntax. The use case for it seems pretty
small and already served by unset().
--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227
Thread (11 messages)