Hello guys,

Zoltan, I think I'm misunderstanding something here. :-/  I have some
questions that will help me understand better:

1) Thinking about the example that uses JS

  globalObject->Set(String::New("context"), instance);
  globalObject->Set(String::New("newGlobal"), globalObject);

  Local<Value> result = CompileRun(
      "(function() {"
      "   with(context)"
      "     with(newGlobal)"
      "       return (function() { valueA + valueB + Math.sin(0) });"
      "})();");

imagine that during compilation 'newGlobal' has valueA. If I
understand correct, you are saying that when I execute the function in
result, it will not perform lookup?

Imagine that we remove it from 'newGlobal' and add another into
'context'. We need another lookup to know that valueA comes from
context and not newGlobal anymore, right? How does v8 knows that it's
time to perform lookup again?


2) The C++ API we have exists to create programatically the construct
with with-statements in JavaScript. So I wasn't really expecting that
we get too much difference from the both approaches. This is how the
feature is implemented today.

> As for cunclusion I would suggest the with statement, since if you happens
> to change the JS engine again, it will still work.

Yes, we get the semantics we want with this approach but the whole
point is that it is slow in current engines :-(  so we have two ways:
(a) optimize the cases we use; (b) find another approach.

For (a) there is the idea that engine could do better if knew that the
objects in with() are "sealed". For (b) there's the approach of
changing the lookup code to match our semantics.


Cheers,


-- 
Caio Marcelo de Oliveira Filho
OpenBossa - INdT
_______________________________________________
Qt-script mailing list
[email protected]
http://lists.qt.nokia.com/mailman/listinfo/qt-script

Reply via email to