What would a 1JS-friendly strict mode look like?

Felipe Nascimento de Moura felipenmoura at gmail.com
Thu Dec 18 09:50:48 PST 2014


did anyone see my suggestion?
(actually, am not sure my e-mails are going out!)

Personally(again, my opinion), I think it is at least weird, having a
"floating string" on your code! Specially because(by now) this is the only
situation, with only one option, what makes it an "exception".
ES has so many great patterns, the least exceptions for the rules, the
better!
That's why I thought about a "scope" token/accessor.
Besides that, some advantages such as enabling experimental features or
not, safe mode, etc.
When I think about it, new ideas come!
Let's say you may use:

scope.set("debug", ["error", "call");

and this would cause any function call inside this scope, to stop(if a
console is opened) pausing the flow for debugging, or also, when any error
occur inside it.
Other things could be done to log calls, as well(changing the verbosity of
the scope).

Sorry if this idea is stupid and I can't see it! hehe

Regards.



On Thu, Dec 18, 2014 at 3:15 PM, Mark Miller <erights at gmail.com> wrote:
>
> I didn't know that SpiderMonkey did that, but I agree it is better. In
> light of this news, I'm glad my code sample doesn't work ;).
>
> As for "would be good for all engines to act the same", the
> precondition was carefully crafted so that engines did not need to
> retain the original source, but rather, just enough for behavioral
> equivalence. Nevertheless, if we could get everyone to agree on
> SpiderMonkey's behavior here, it would be better. Too late for ES6
> though.
>
>
>
> On Thu, Dec 18, 2014 at 9:09 AM, Till Schneidereit
> <till at tillschneidereit.net> wrote:
> >
> >
> > On Thu, Dec 18, 2014 at 6:01 PM, Mark S. Miller <erights at google.com>
> wrote:
> >>
> >> (1,eval)("" + function(){...strict code you want to execute
> sloppy...})()
> >
> >
> > This doesn't work in SpiderMonkey: stringifying functions retains their
> > strictness, no matter where strict mode is activated. In this case, the
> > result would be the string 'function (){\n"use strict";\n...strict code
> you
> > want to execute sloppy...}'
> >
> > It's unfortunate that this doesn't behave the same in all engines, but I
> > would argue that SpiderMonkey's stringification is the more faithful one.
> >
> > _______________________________________________
> > es-discuss mailing list
> > es-discuss at mozilla.org
> > https://mail.mozilla.org/listinfo/es-discuss
> >
>
>
>
> --
> Text by me above is hereby placed in the public domain
>
>   Cheers,
>   --MarkM
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>


-- 
*Felipe N. Moura*
Senior Web Developer

Website:  http://felipenmoura.org
Twitter:    @felipenmoura <http://twitter.com/felipenmoura>
LinkedIn: http://goo.gl/qGmq

Meet some of my projects:
BrazilJS Conference <http://braziljs.com.br/>  |  BrazilJS Foundation
<http://braziljs.org>  |  Power Polygon
<http://github.com/braziljs/power-polygon>  |  TheWebMind
<http://thewebmind.org/>  |  PHPDevBar
<https://addons.mozilla.org/pt-BR/firefox/addon/php-developer-toolbar/>
---------------------------------
LinuxUser #508332
*Changing  the  world*  is the least I expect from  myself!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20141218/d582d365/attachment-0001.html>


More information about the es-discuss mailing list