-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What is the purpose of performing the Link() algorithm many times? #3474
Comments
This means that consumers have less states to think about, and that all transitions across the possible states that a consumer can see are easily definable:
Intermediate states would be impossible to handle for consumers: for example, what do you do with a module that is
It's conceptually easier to not have a cache than to have one, if the cache is not observable. Implementations can instead optimize the spec algorithms by adding caches wherever they want, as long as they have the same observable behavior of the spec (i.e. the cached-and-rethrown linking error must not be |
You can just leave it as is, but borrow the strategy from the Evaluate() phase: What do you think? Wouldn't it be simpler? As for the observed behavior and caches that implementations can implement, it is clear. |
If you look at the history of modules in the ECMAScript specification, it has been constantly changing. Although some things have remained as they were originally invented in ES6.
My question is about the architecture of modules, and specifically about why the Link() algorithm can change the
[[Status]]
field of a module from linking to unlinked? This happens in the only case when a Syntax Error occurs in the InitializeEnvironment() method of a module, due to a binding resolution error.If you look at ES6, there, if a module received the Module Environment Record value in the
[[Environment]]
field once, then the algorithm noticed this and reset further ModuleDeclarationInstantiation() steps the next time. This happened both in the case of a binding resolution error for a module and in the case when ModuleDeclarationInstantiation() was successful the algorithm simply did not reach the second binding resolution.Now this algorithm ModuleDeclarationInstantiation() is broken down into Link() -> InnerModuleLinking(module, stack, index) -> InitializeEnvironment(). And if before it did not execute the algorithm more than once in any case, now it has a loophole that allows you to execute Link() again in full if an error is detected in resolving bindings.
Why was this done? What was achieved this way? Recalculate the error result, which we already know from the first calculation, what's the point?
The text was updated successfully, but these errors were encountered: