On 2/10/11 10:32 PM, timeless wrote:
i believe the only requirements for:

<script>
function x(){....}
function y(){....}
</script>

are:
1. if x fails to compile, y is not evaluated
2. y can fail to compile too
3. if something fails to compile, window.onerror is triggered
4. if x could compile, then window.x is defined to be a Function object

I don't think so. If there is any parse or compilation or whatever you want to call it error, the script is never executed, so window.x is never defined.

Also, I would fully expect it to be a web compat requirement that window.onerror not be triggered until the script would be evaluated. If you parse/compile/whatever before that and hit an error, you'd need to save that and report it at the "right" time.

Which means the that parse/compile/whatever process is currently not observable directly. And that's a good thing!

in theory, i believe a js engine could choose to discard all work it
has done to validate syntax for x+y beyond saving those coordinates,
and then either do the proper ast / bytecode / machine code generation
lazily (or schedule to do it on a thread).

Sure; a js engine could also not do any syntax validation at all, until it needs to run the script...

-Boris

Reply via email to