Re: Lexical scoping
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 ){{
$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.
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/
Thread (11 messages)