Le 4 déc. 2012 à 22:28, Brendan Eich <bren...@mozilla.org> a écrit :

> Mark S. Miller wrote:
>> On Tue, Dec 4, 2012 at 10:48 AM, Brendan Eich<bren...@mozilla.org>  wrote:
>>> Kevin Smith wrote:
>>>> I recommend allowing let declarations only in strict mode.  This is the
>>>> simple, backwards-compatible path.  Strict mode only has a bad reputation
>>>> because, in ES5, it is restrictive-only.  There are (almost) no carrots
>>>> leading users there.
>>> Strict mode has a bad rep for two other important causes:
>>> 
>>> * It forks runtime semantics, which requires careful testing in
>>> pre-ES5-strict implementations. This has been a real-world problem, multiple
>>> times.
>> 
>> I buy this for old code that needs to just keep working, bugs and all,
>> without human attention. But strict mode can be opted into
>> incrementally, per program or even per function.
> 
> Real world problem: concatenation.
> 

If we allow "let" and destructuring assignment in non-strict mode, a
developer will happily use "let" as variable name, then one day they
will write "let[i] = j" (Murphy's law), and get an incomprehensible
failure. Moreover, strict and non-strict mode, will not be very
different, and people will continue to accidentally swap between them,
which will lead to occasional and sometimes insidious bugs.

On the other hand, if we disallow "let" and/or destructuring assignment
in non-strict mode, whenever some code using these features is
accidentally run as non-strict, it is almost guaranteed that there will
be an immediate and loud failure.  Because this hazard will happen
relatively often, it will help to make generally known that strict and
non-strict are *indeed* incompatible, and, in turn, reduce the chance of
incompatible concatenation of strict and non-strict scripts.

As developer, I prefer a loud failure over a smart engine which might
silently misinterpret my code in an apparently non-regular way. It is
much easier to debug. Please, do not add too smart parsing rules into
the language.

Claude


>>  <snip>

_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to