Re: Lexical scoping
| From: | Andrea Faulds | Date: | Tue, 28 Jan 2014 16:07:57 +0000 |
| Subject: | Re: Lexical scoping | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-71676@lists.php.net to get a copy of this message | ||
On 28/01/14 13:36, George Bond wrote:
Alternatively, you could say that the ultimate problem is that we don't have strong scoping - braces only define flow control, not scope. So you could introduce a strong-scoping structure. Maybe a double brace? foreach( $array as &$a ){{My proposal is to add optional strong scoping. As JavaScript has var for function-scoped variables and ECMAScript Harmony will add let for lexically-scoped variables, I'm proposing something similar here. It would allow you to scope to the block, if you so desire. -- Andrea Faulds http://ajf.me/$a = 3;}} var_dump( $a ); // E_NOTICE, $a is now undefined You could even say that an isolated brace pair (ie not one following a control statement) *always* produces a scope.