On Jul 7, 2016 1:11 PM, Jason Orendorff <[email protected]> wrote:
>
> On Thu, Jul 7, 2016 at 12:09 PM, Caridy Patiño <[email protected]> wrote:
>>
>> Moving step 7 to the end is not an option since the primary use of that step is to support circular references.
>
>
> Not sure this is helpful, but back when I was working with Dave on this stuff, it was supposed to work something like this:
>
> * The loader determines when a set of new modules is ready to link. This only happens after resolving all requested modules for the whole set.
>
> * Check that all requested modules actually have the export bindings we require of them. If not, it's an error.
>
> * Linking. We create module Environments and all their bindings, including import bindings. Observably, this is an atomic step and it can't fail. We already checked for all possible link errors.
Yup, that's also how the spec. is structured.
>
> * Next, we evaluate module bodies, etc.
>
> So in our design, if code ran in a module environment, that environment was fully linked. It looks like ModuleDeclarationInstantiation does not have this guarantee. If true, that's a serious bug.
It isn't true. No user code runs while linking/instantiating a graph of modules. Evaluation is a separate step that only happens if the linking/instantiation occurs without error.
>
> > As for recovering from errors, this is in the realm of the loader and the registry to prevent subsequence attempts to instantiate a source text module record that failed already. [...]
Yup
>
> It's fine to have an error sometimes shoot down a whole graph of modules. The problem here is that the failed Environments can be exposed later. The spec says you're even supposed to run code in them, right? But forging ahead with partially-initialized data structures seems as obviously undesirable in a spec as in running code -- that's begging for bugs -- and it's an unreasonable implementation burden too.
The spec. Only generates errors and does try to define error recovery. That's up to the implementation. But I would expect implementations to discard any module records it created during a linking phase that throws errors.
Allen
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

