restrictions on let declarations

Oliver Hunt oliver at apple.com
Thu Jan 30 11:35:09 PST 2014


On Jan 30, 2014, at 11:27 AM, John Lenz <concavelenz at gmail.com> wrote:

> I don't argue that it isn't a useless "let".  I do point out that in "sloppy" mode, that other declaration are allow in practices by browsers.  Chrome allows function, const, and var in the body of an if without block.  
That’s because they _have_ to be allowed as these constructs are used on millions (billions?) of web pages.  Disallowing that behaviour would break the web and we can’t do that.

Introducing new constructs that expose the same coding problems is not worth it - maybe we would want to change something in the future but we would already have been burned by existing content using this code incorrectly.

—Oliver

> 
> It does seems like an unnecessary restriction, and with it I'll need to make sure that Closure Compiler doesn't introduce these when stripping blocks, not a big deal just one more thing to deal with.
> 
> I was just hoping that the restriction was enabling something and not just noise.
> 
> 
> On Thu, Jan 30, 2014 at 11:00 AM, Brendan Eich <brendan at mozilla.com> wrote:
> John Barton wrote:
>  Not silly. Can you suggest any on-line that most JS developers can understand discussing how these two forms differ?
> 
> Here are some that describe them as equivalent:
> 
> http://en.wikipedia.org/wiki/JavaScript_syntax#If_..._else
> http://msdn.microsoft.com/en-us/library/kw1tezhk(v=vs.94).aspx <http://msdn.microsoft.com/en-us/library/kw1tezhk%28v=vs.94%29.aspx>
> 
> http://programmers.stackexchange.com/questions/16528/single-statement-if-block-braces-or-no
> http://publib.boulder.ibm.com/infocenter/comphelp/v7v91/index.jsp?topic=%2Fcom.ibm.vacpp7a.doc%2Flanguage%2Fref%2Fclrc08csor.htm
> http://msdn.microsoft.com/en-us/library/ms173143.aspx
> 
> and so on across multiple languages.  Whether or not you think these forms should be different, programmers don't expect them to differ.
> 
> This is all beside the point, since the unbraced let as consequent of if cannot make a useful binding (if you use comma-separated multiple declarators, you still can't use any of the values that initialize the bindings except in later useless-outside-the-single-declaration consequent).
> 
> /be
> 
> _______________________________________________
> 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/20140130/4a1d43ec/attachment.html>


More information about the es-discuss mailing list