There currently isn't any such API and it is debatable whether or not one is 
actually needed.

In most cases, "strict mode" will be explicitly specified in lexically 
enclosing code (ie, in the same source file) so the code hypothetically wanting 
to make this test should already know whether or not it is strict mode code.

The only situation where strict mode might not be lexically obvious would be 
code that is injected via a direct call to eval. The strictness of direct 
eval'ed code (that does not have a "use strict" directive) is determined by the 
strict mode of the caller of eval so if the source code passed to eval came 
from a "foreign" source it might not have been known when it was written 
whether or not is was going to execute in strict mode. 

There are a number of coding idioms that could be used to dynamically determine 
whether or not code is operating in strict mode. I guess the question really is 
whether those idioms are adequate for the above eval based scenario.

Allen



>-----Original Message-----
>From: [email protected] [mailto:es-discuss-
>[email protected]] On Behalf Of kevin curtis
>Sent: Friday, April 17, 2009 6:52 PM
>To: [email protected]
>Subject: Re: ecmascript 5 and the script tag
>
>If a script (or Program) has the 'use strict' directive is there an
>api or flag for querying if the script is 'strict'. Both at the
>ecmascript level and at the api c/c++ level. Or should the developer
>(either in ecmascript or c/c++) examine the first line of source code
>for the 'use strict' directive. (The same goes for functions).
>_______________________________________________
>es-discuss mailing list
>[email protected]
>https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to