Hopefully last word on Use Strict Directive syntax

Waldemar Horwat waldemar at google.com
Tue Jun 9 14:00:46 PDT 2009

Allen Wirfs-Brock wrote:
>> -----Original Message-----
>> From: Waldemar Horwat [mailto:waldemar at google.com]
> ...
>>> On the other hand, I don't see any particular reason to disallow semi-
>> colon insertion within the Directive Prologue. Given that we have it
>> (even in strict mode) why would we disallow it here? It just adds
>> specification complication and an additional special case for users to
>> learn.
>> You disallowed it previously, so I was simply expressing surprise at the
>> change in your last email.  There was no discussion of this at the last
>> meeting.
> It was motivated by the addition of the possibility of multiple expression statements in a Directive Prologue.  
> As soon as you have multiple "statements" semicolon insertion seems like a reasonable idiom for this language.
>> Not sure what the technical ramifications are one way or another.
>> They're probably limited to confusion if an implementation provides a
>> use-directive that turns off semicolon insertion and other use-
>> directives are used without a semicolon.  If you get into the habit of
>> omitting semicolons, you can also run into trouble with things that look
>> like they're strict but are not:
>> function f(x) {
>>  "use strict"
>>  +x ? delete p : delete q;
>> }
> The above example seems like a pretty good reason to require explicit semicolons in the Directive Prologue although I guess the same hazard exists for all expression statements, not just directives.

I'm mainly worried about people mechanically pasting in the line

  "use strict"

into existing code without looking to see what follows.  Of course you can also argue that this would also not work if we required semicolons, but at least it would be consistent in not working and I hope implementations would warn about the missing semicolon.


More information about the es5-discuss mailing list