Hopefully last word on Use Strict Directive syntax

David-Sarah Hopwood david-sarah at jacaranda.org
Tue Jun 9 15:59:17 PDT 2009

Allen Wirfs-Brock wrote:
>> 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.

That case could very easily be specified to be an error.

>> 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;
>> }

This hazard, OTOH, can't be fixed, because the "use strict" is not a
directive in this case, and you would have to know that it is a directive
before you could require a semicolon after it.

David-Sarah Hopwood  ⚥  http://davidsarah.livejournal.com

More information about the es5-discuss mailing list