On the one hand, the point of eager execution was to make the execution model simple and consistent with corresponding IIFE code.

When we switch from scripts to modules, it makes sense to switch
from execute-as-encountered-for-side-effect to resolve-dependencies-
and-extract-exports. The former may use IIFEs to limit the scope of
some side-effects, the latter uses functions and results to avoid side-effects (*).

(a) execute inline modules by need (i.e., on first import) rather than eagerly

The weird thing about (a) is that code that appears to be straight-line actually executes in somewhat more unpredictable (although deterministic) order.

Think of a module as a function and import declarations as function calls. Only difference is the sharing of evaluation (each module body
is only run once), with caching of results (exports).

Claus

(*) http://libraryinstitute.wordpress.com/2010/12/01/loading-javascript-modules/

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to