|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
|
|
|
Re: Section 13.2: Rationale for "caller", "arguments" restrictionOn Tue, May 26, 2009 at 6:05 PM, Mark S. Miller <erights@...> wrote:
A better laundry: function laundry(fun, thisArg, args) { "use strict"; return fun.apply(thisArg, args); } -- Cheers, --MarkM _______________________________________________ es-discuss mailing list es-discuss@... https://mail.mozilla.org/listinfo/es-discuss |
|
|
Re: Section 13.2: Rationale for "caller", "arguments" restrictionOn Tue, May 26, 2009 at 8:05 PM, Mark S. Miller <erights@...> wrote:
> To fix this problem, we need one additional bit of poison: If > arguments.caller or bar.caller would reveal a strict function, they should > return something harmless instead. I suggest that undefined is a perfectly > fine harmless value. No, if adding "use strict" is going to break real-world code, ES5 should throw an exception. I hope I don't need to justify that stance; we've been there, heard that, right? (The arguments have to do with workaday web developers who aren't designing object-capability sandboxes.) I'm not aware of any silent behavior changes in strict mode as defined in the draft. Throwing here lets the implementation provide an error message that clearly blames the caller's strictness. Or, more properly, Mark himself: "Strict function f can't call nonstrict function g because g uses arguments.caller, which would expose f to tampering if g is evil. You can thank Mark Miller for this one." ;-) (Here the message exposes that f is strict, and even its name, but I don't see how or why that is to be avoided.) > If this poison is not swallowed, then SES can still cope by > translating all function calls to go through a harmless laundry > function: With getters and setters that will be quite a bit worse, right? Every property access would have to be translated into something that inspects the object rather carefully. -j _______________________________________________ es-discuss mailing list es-discuss@... https://mail.mozilla.org/listinfo/es-discuss |
|
|
Re: Section 13.2: Rationale for "caller", "arguments" restrictionOn 05/26/2009 06:05 PM, Mark S. Miller wrote:
> JavaScript has one and only one encapsulation mechanism -- functions > evaluating to closures that encapsulate their captured variables. > However, the existence of these de-facto properties pokes a fatal hole > in this mechanism, leaving us with no defensible boundary. I appreciated the example on the slide you linked to. Providing .caller does seem to be problematic. However, what you wrote above confused me. The things encapsulated by a closure are the variables it refers to from lexically enclosing scopes. What you wrote suggests that .caller somehow makes those available to others, which isn't so, as far as I can tell. The closure's arguments can be obtained, but those are different. The mechanism with the hole is the dynamic link, not the static link. _______________________________________________ es-discuss mailing list es-discuss@... https://mail.mozilla.org/listinfo/es-discuss |
| Free embeddable forum powered by Nabble | Forum Help |