January 19 meeting notes

Allen Wirfs-Brock allen at wirfs-brock.com
Fri Jan 20 09:26:36 PST 2012


On Jan 20, 2012, at 6:22 AM, Herby Vojčík wrote:

> Andreas Rossberg wrote:
>> On 20 January 2012 01:40, Waldemar Horwat<waldemar at google.com>  wrote:
>>> Also, "function (e) {let e;}" should always be an error.
>> 
>> Is there a good reason to do this? It would be an unnecessary
>> irregularity with block scoping, and seems like overly nanny-ish (in
>> stark contrast to other parts of the language).
> 
> +1. I see no point why let e; should not shadow argument e here.

In general, the binding rules for function parameters were decided at the Nov. 2011 meeting (see Nov 16 meeting notes):  

> MarkM: Two-scope model (one scope for parameters, an independent inner scope for let, const, and var bindings).  This model is upwards-compatible with ES5.1 strict because the latter disallows shadowing of a parameter by a binding in function scope.
> 
> Allen: Two-scope model, but with inner scope prohibited from shadowing parameters.
> MarkM: Likes this.  Any program that is accepted works with either of the two-scope model intuitions.

Whether you view this has two scopes with static semantic rules that prohibit inner declarations from shadowing or a single scope with appropriate static semantic rules that prevent redeclaration of  formals, the effect is essentially the same.  The current specification draft actually uses a single environment record and appropriate static semantic rules. However you model it in terms of scopes, the intent is that the function formal parameters and the top level declarations are treated as a single naming contour for the purposes of allowing or disallowing duplicate declarations. 

Also we have the following rules such such naming contours:
We don't allow duplicate let declarations for the same name.
We don't allow a let binding and a var declarations for the same name.
There may be multiple var declarations for the same name.  They all refer to the same binding.


Given those rules, how to we think about formal parameters?  If they are equivalent to let declarations, then the first rule would disallow function(d) {let e}.  If they are equivalent to var declarations, then the second rule would disallow that function.

Allen








> 
> Herby
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120120/067d3f0c/attachment-0001.html>


More information about the es-discuss mailing list