On 11 June 2013 19:56, Michael Schwartz <[email protected]> wrote:
> [...]
>
> Invocation might be something like:
>
> var o = {
>   out: '',
>   write: function(s) { o.out += s; },
>   writeln: function(s) { o.out += s + '\n'; }
>   obj: { title: 'whatever', otherMetaData: … }
> };
> with (o) {
>    eval(script);
> }
> ...
> document.write(o.out);

And what's wrong with replacing this by the following?

{
 let out = ''
 function write(s) { o.out += s; },
 function writeln(s) { o.out += s + '\n'; }
 let obj = { title: 'whatever', otherMetaData: … }
 eval(script);
}

Moreover, if the script code is generated anyway, why not simply
generate a function like:

function(o) {
  o.writeln('<head>');
  o.write('<title>');
  o.write(obj.title);
  o.writeln('</title>');
  o.writeln('<body>');
  for (i=1; i<6; i++) {
    o.write('<div>Line #');
    o.write(i);
    o.writeln('</div>');
  }
  o.writeln(</body>');
  o.writeln(</html>');
}

Invoke as:

  eval(script)(o)

So I don't see how your example is an argument for 'with'. Seems
completely unnecessary.

/Andreas

-- 
-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to