actually, interesting enough, function expressions do not suffer this
problem ... this is getting weirder and weirder ...
with(this){
alert(function isStrict() {"use strict";
return this;
}()); // undefined
}
br
On Wed, Jan 30, 2013 at 9:00 AM, Andrea Giammarchi <
[email protected]> wrote:
> let me rephrase ...
>
> putting `with(this){` before any build process/inlined library and `}` at
> the end of all concatenated files **nothing** is strict anymore ^_^
>
> function isStrict() {"use strict";
> return this;
> }
>
> isStrict(); // undefined
>
> now, wraping the whole thing inside a with statement
>
> with(this){
> function isStrict() {"use strict";
> return this;
> }
> alert(isStrict()); // global object
> }
>
> forget the Function hack, there is no library able to ensure itself to be
> executed in strict mode.
> Using the width statement around any code makes it not strict.
>
> Thoughts ?
>
>
>
>
>
>
>
>
>
> On Wed, Jan 30, 2013 at 8:19 AM, Brandon Benvie <[email protected]
> > wrote:
>
>> Correction, the use strict directive needs to appear as the first
>> statement (ExpressionStatement) that's not an EmptyStatement and not a
>> FunctionDeclaration. Anything else will cause the directive to be ignored.
>>
>>
>> On Wed, Jan 30, 2013 at 11:15 AM, Brandon Benvie <
>> [email protected]> wrote:
>>
>>> To enable strict mode, the "use strict" expression must come as the
>>> first non-statement of a script or function body. That means
>>> function x(){}
>>> "use strict";
>>>
>>> Will enable strict mode, but
>>>
>>> (function x(){});
>>> "use strict";
>>>
>>> won't. To make your example strict, you'd have to do
>>>
>>> with (ob) {
>>> (function(){
>>> "use strict'";
>>> /* concatenated stuff */
>>> })();
>>> }
>>>
>>>
>>> On Wed, Jan 30, 2013 at 10:48 AM, Claude Pache
>>> <[email protected]>wrote:
>>>
>>>> Le 30 janv. 2013 à 06:12, Andrea Giammarchi <
>>>> [email protected]> a écrit :
>>>>
>>>> I have a blog post about it called
>>>>
>>>> Resurrecting The With Statement
>>>>
>>>> and before I post the link, there the long story short:
>>>>
>>>> putting `with(this){` before any build process/inlined library and `}`
>>>> at the end of all concatenated files nobody is strict anymore ^_^
>>>>
>>>>
>>>> For what I understand of ES5, putting some random stuff (other than
>>>> string literals or comments) before a "use strict" directive at the
>>>> beginning of a file will disable it. This is a known fact, orthogonal to
>>>> the "Function + with" dirty/creative hack of your blog post.
>>>>
>>>> —Claude
>>>>
>>>>
>>>>
>>>> http://webreflection.blogspot.com/2013/01/resurrecting-with-statement.html
>>>>
>>>>
>>>> I actually like this possibility, but I'd like to know what you think
>>>> about it
>>>>
>>>>
>>>> br
>>>> _______________________________________________
>>>> 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
>>>>
>>>>
>>>
>>
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss