Repository navigation
Split out compileAndInstantiate from instantiate - #999
Closed
lukewagner wants to merge 1 commit into
Closed
lukewagner wants to merge 1 commit into
lukewagner wants to merge 1 commit into
Conversation
Member
Author
|
Sadly, it's too late to make such a breaking change, sorry for the noise. This would've been nice to have, but it's not necessary. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I think there would be a number of benefits from having
instantiatealways return aPromise<Instance>and having a separatecompileAndInstantiatethat returns thePromise<{module,instance}>. In this PR,instantiateis still able to take all the same things it does now, and thus, this PR is strictly more expressive than the current state. (It's also a pretty simple change to implement.)The benefits I see of this PR are:
instantiateis less surprising;compileAndInstantiatereturning a pair is implied by the name.instantiateis just a sink for all manner of byte-y things that always produces anInstance. I was feeling this acutely while writing MDN docs/tutorials recently.instantiate, the engine would know up front that theModulewon't be needed and that the generated code can't be instantiated multiple times, serialized or shared. This can allow for more efficient compilation, more aggressive specialization and less garbage generated by compilation.instantiateGroup(Support multi-module 1-step Instantiate with dependencies #997): given that this function takes a map of inputs and produces a map of outputs: are the output valuesInstances or{module,instance}pairs? Do we have it depend on the dynamic types of values in the input map? What if some of the input values areModules and some are not? Do we instead break symmetry and have it always return a{module,instance}pair? After this PR, the obvious, symmetric thing would be to have bothinstantiateGroupandcompileAndInstantiateGroupwhich makes the output type clear.