Alternative to Mozilla's eval in a scope

ihab.awad at gmail.com ihab.awad at gmail.com
Sun Dec 13 21:56:59 PST 2009


Hi Andy,

On Sun, Dec 13, 2009 at 9:49 PM, Andy Chu <andy at chubot.org> wrote:
> There is a function called "loadCode" for now, that behaves a little
> bit like eval:
>
> var code = loadCode("var foo=3; var bar = function(a) { fn(a) };",
> {fn: obj.fn});
>
> // code is now {foo: 3, bar: function(a) ...}

Where is this loadCode function implemented? Is this something you
wrote yourself?

In the Caja project, our "isolated evaluator" is implemented to return
the value of the last ExpressionStatement in the code. In other words,
the loaded code is more easily able to defend its *own* integrity
since its top-level vars are private to it.

Ihab

-- 
Ihab A.B. Awad, Palo Alto, CA


More information about the es-discuss mailing list