On Mon, Feb 15, 2016 at 11:51 PM, Andreas Rossberg <rossb...@google.com> wrote:

> That would be a total and complete disaster for implementations, as it would
> make scopes observable and mutable in a way that absolutely breaks all
> conventional compilation and optimisation techniques for local variables,
> closures, etc. JavaScript would easily become 10-100x slower. Like when you
> use `with` today.

It was not my plan to move closed-over values and local variables into
an Object as part of a chain of prototyped, inherited objects.  I only
wanted to make it possible to set the "global" environment, and have
that object follow prototypical inheritance.

To this I would ask - which specific optimisations would it compromise?

> It would totally break security as well, given that functions could then
> peek into local variables on their call chain through __proto__. And I
> cannot even fathom what it would mean to mutable some __proto__!

In what I envisioned, it would not expose local or closed-over
variables - they would not be part of the environment Object I'm
talking about.

My inspiration is that you could prepare sandbox environments that you
construct and derive from cleanly - without using something like the
`vm` module only found in Node.  Currently if you want to "sandbox"
the environment in the browser you have to lose references to things
you consider dangerous (of course) - but that is "forever".  You
cannot leave any reference to anything unsafe and once it's done it's
done.  Having the ability to derive from "global" (only in Node) and
prepare an Object to run an function within as its global context
would be an invaluable ability. (imo)
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to