Modules, Concatenation, and Better Solutions

Claus Reinke claus.reinke at
Wed Oct 17 01:27:45 PDT 2012

>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).



More information about the es-discuss mailing list