Modules: compile time linking (was Re: Modules feedback, proposal)
John J Barton
johnjbarton at johnjbarton.com
Fri Apr 6 08:47:54 PDT 2012
On Fri, Apr 6, 2012 at 4:54 AM, Sam Tobin-Hochstadt <samth at ccs.neu.edu>wrote:
> On Thu, Apr 5, 2012 at 11:23 PM, John J Barton
> <johnjbarton at johnjbarton.com> wrote:
> > On Thu, Apr 5, 2012 at 10:01 AM, James Burke <jrburke at gmail.com> wrote:
> >> So, assuming Math has no dependencies (just to make this shorter), the
> >> sequence of events:
> >> * Load Foo, convert to AST, find "from" usage.
> >> * Load Math
> >> * Compile Math
> >> * Evaluate Math
> >> * Inspect Math's exported module value for properties
> >> * Modify the compiled structure for Foo to convert "import *" to have
> >> local variables for all of Math's properties that are known, only at
> >> this time (no funny dynamic 'with' stuff)
> >> * Evaluate Foo
> > This is certainly the events I expect: is there an alternative? I suppose
> > the module syntax could support moving Evaluate Math to just before
> > Foo. (a la a compiled language) The Math-level operations that created
> > properties would not be known to Foo. That would be a major surprise to
> > I think.
> The properties available to `Foo` are exactly the ones declared with
> `export` in `Math`. I don't think that should be a surprise to
> anyone -- that's what `export` is for.
Ok thanks, now I understand some of the previous discussions. If 'export'
property list is literal, then computation in the Math module can't change
the properties exported, but it can change the properties of those
properties. So we get one level of checking.
The definite and small value of this check must be balanced against the
less clear but possibility larger value of flexibility granted by an
imperative export and JS's traditional compile/run cycle.
However, it is the case that the evaluation of `Math` and of `Foo`
> happen close together, even thought that doesn't make a difference in
> this case. It would potentially make a difference if there was some
> third module that imported from `Foo`.
> sam th
> samth at ccs.neu.edu
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss