Confused about "Reading from the imports object requires knowing the keys"
bakkot opened this issue · 2 comments
... Why? You can do Object.keys(x) or [if you want things from the prototype] the equivalent of for (x in y). And sure, that might throw if the user has provided a Proxy with a throwy keys traps, but... so what? Why bother worrying about that?
The issue is if you're trying to have parity with how the JS-API spec handles import objects. In the existing JS-API it does a property get driven by the imports section of the module.
So yes, we could define a different way of reading an import object for compile-time imports, such as the ones you propose. See #2 for one using the iterator protocol.
I should note too that proxies are actually used as import objects today in real-world code. We probably don't need to support them with compile-time imports, but the reason I proposed the array based imports objects was so that it had a different shape to really emphasize it was interpreted differently by the API.