should we rename the Program grammar production?

Brendan Eich brendan at mozilla.com
Thu Oct 11 12:09:36 PDT 2012


John J Barton wrote:
> On Thu, Oct 11, 2012 at 11:03 AM, Brendan Eich<brendan at mozilla.com>  wrote:
>> John J Barton wrote:
>>> That is not my understanding, but I don't think it matters: that is an
>>> implementation specific notion without consequence. Whether the
>>> compiler treats all of the top level statements of a<script>   tag
>>> individually or separately cannot influence the result.
>> No, this ignores function and var hoisting.
>
> So that just means functions aren't the unit of compilation as
> previously claimed right?

No, it means your statement "[w]hether the compiler treats all of the 
top level statements of a<script> tag individually or separately cannot 
influence the result"is not true.

Engines indeed must parse whole scripts but need not "compile every 
function" at that time, so some engines are indeed deferring anything 
beyond parsing until first call to a function. This means that any 
nested functions and vars, while also parsed, have their compilation to 
something executable deferred too. The skeletal parsing does not even 
necessarily save a parse tree to interpret.

This deferred compilation is not observable, indeed.

> In any case, I only want to bolster Allen's suggestion to add a new
> word for code fed to the compiler before execution.

The best of a bad lot, IMHO, is still "Script".

/be


More information about the es-discuss mailing list